1
1
// RUN: %empty-directory(%t)
2
2
3
- // RUN: %target-build-swift %s -Xfrontend -disable-availability-checking -parse-as-library -o %t/async_task_priority
4
- // RUN: %target-codesign %t/async_task_priority
5
- // RUN: %target-run %t/async_task_priority
3
+ // RUN: %target-build-swift %s -Xfrontend -disable-availability-checking -parse-as-library -o %t/async_task_escalate_priority
4
+ // RUN: %target-codesign %t/async_task_escalate_priority
5
+ // RUN: %target-run %t/async_task_escalate_priority
6
6
7
7
// REQUIRES: VENDOR=apple
8
8
// REQUIRES: executable_test
24
24
25
25
import Darwin
26
26
@preconcurrency import Dispatch
27
- import StdlibUnittest
28
27
29
28
func loopUntil( priority: TaskPriority ) async {
30
29
var loops = 10
@@ -77,8 +76,7 @@ func testNestedTaskPriority(basePri: TaskPriority, curPri: TaskPriority) async {
77
76
78
77
let top_level = Task . detached { /* To detach from main actor when running work */
79
78
80
- let tests = TestSuite ( " Task Priority escalation " )
81
- tests. test ( " Basic task_escalate when task is running " ) {
79
+ func basicTask_escalateWhenTaskIsRunning( ) async {
82
80
let sem1 = DispatchSemaphore ( value: 0 )
83
81
let sem2 = DispatchSemaphore ( value: 0 )
84
82
let task = Task ( priority: . background) {
@@ -97,8 +95,9 @@ func testNestedTaskPriority(basePri: TaskPriority, curPri: TaskPriority) async {
97
95
Task . escalatePriority ( task, to: . default)
98
96
sem2. wait ( )
99
97
}
98
+ await basicTask_escalateWhenTaskIsRunning ( )
100
99
101
- tests . test ( " Trigger task escalation handler " ) {
100
+ func triggerTaskEscalationHandler ( ) {
102
101
let sem1 = DispatchSemaphore ( value: 0 )
103
102
let sem2 = DispatchSemaphore ( value: 0 )
104
103
let semEscalated = DispatchSemaphore ( value: 0 )
@@ -134,8 +133,9 @@ func testNestedTaskPriority(basePri: TaskPriority, curPri: TaskPriority) async {
134
133
semEscalated. wait ( )
135
134
sem2. wait ( )
136
135
}
136
+ await triggerTaskEscalationHandler ( )
137
137
138
- tests . test ( " Trigger twice: Escalate to medium, and then again to high " ) {
138
+ func triggerTwice_escalateToMediumAndThenAgainToHigh ( ) {
139
139
let sem1 = DispatchSemaphore ( value: 0 )
140
140
let semEscalatedMedium = DispatchSemaphore ( value: 0 )
141
141
let semEscalatedHigh = DispatchSemaphore ( value: 0 )
@@ -176,8 +176,9 @@ func testNestedTaskPriority(basePri: TaskPriority, curPri: TaskPriority) async {
176
176
// we got escalated twice
177
177
semEscalatedInHandler. wait ( )
178
178
}
179
+ await triggerTwice_escalateToMediumAndThenAgainToHigh ( )
179
180
180
- tests . test ( " Don't trigger in already escalated task " ) {
181
+ func dontTriggerInAlreadyEscalatedTask ( ) {
181
182
let sem1 = DispatchSemaphore ( value: 0 )
182
183
let sem2 = DispatchSemaphore ( value: 0 )
183
184
let semEscalated = DispatchSemaphore ( value: 0 )
@@ -219,8 +220,7 @@ func testNestedTaskPriority(basePri: TaskPriority, curPri: TaskPriority) async {
219
220
semEscalated. wait ( )
220
221
sem2. wait ( )
221
222
}
222
-
223
- await runAllTestsAsync ( )
223
+ await dontTriggerInAlreadyEscalatedTask ( )
224
224
}
225
225
226
226
await top_level. value
0 commit comments