Skip to content

Commit 7226c67

Browse files
authored
Merge pull request #38363 from DougGregor/racy-sleep-test-5.5
Dial back a racy race test for `Task.sleep(nanoseconds:)`.
2 parents 996ced8 + 23662ef commit 7226c67

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

test/Concurrency/Runtime/async_task_sleep_cancel.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import Dispatch
5555
static func testSleepCancelledBeforeStarted() async {
5656
// CHECK-NEXT: Testing sleep that gets cancelled before it starts
5757
print("Testing sleep that gets cancelled before it starts")
58-
let start = DispatchTime.now()
59-
6058
let sleepyTask = Task {
6159
try await Task.sleep(nanoseconds: UInt64(pause))
6260
}
@@ -65,20 +63,14 @@ import Dispatch
6563
sleepyTask.cancel()
6664
try await sleepyTask.value
6765

68-
fatalError("sleep(nanoseconds:) should have thrown CancellationError")
66+
print("Bah, weird scheduling")
6967
} catch is CancellationError {
70-
// CHECK-NEXT: Caught the cancellation error
7168
print("Caught the cancellation error")
72-
73-
let stop = DispatchTime.now()
74-
75-
// assert that we stopped early.
76-
assert(stop < (start + .nanoseconds(pause)))
7769
} catch {
7870
fatalError("sleep(nanoseconds:) threw some other error: \(error)")
7971
}
8072

81-
// CHECK-NEXT: Cancelled!
73+
// CHECK: Cancelled!
8274
print("Cancelled!")
8375
}
8476

0 commit comments

Comments
 (0)