Skip to content

Commit 879ce16

Browse files
authored
Merge pull request swiftlang#38093 from DougGregor/async-stream-race-tests-5.5
[Concurrency] Remove some tests that are inherently race conditions from AsyncStream
2 parents 3a19e58 + 5956c08 commit 879ce16

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

test/Concurrency/Runtime/async_stream.swift

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -399,60 +399,6 @@ var tests = TestSuite("AsyncStream")
399399
expectTrue(expectation.fulfilled)
400400
}
401401

402-
tests.test("cancellation behavior of value emitted in handler") {
403-
let ready = DispatchSemaphore(value: 0)
404-
let done = DispatchSemaphore(value: 0)
405-
let task = detach {
406-
let series = AsyncStream(String.self) { continuation in
407-
continuation.onTermination = { @Sendable _ in continuation.yield("Hit cancel") }
408-
}
409-
ready.signal()
410-
var iterator = series.makeAsyncIterator()
411-
let first = await iterator.next()
412-
expectEqual(first, "Hit cancel")
413-
let second = await iterator.next()
414-
expectEqual(second, nil)
415-
done.signal()
416-
}
417-
ready.wait()
418-
task.cancel()
419-
let result = done.wait(timeout: DispatchTime(uptimeNanoseconds: DispatchTime.now().uptimeNanoseconds + 1_000_000_000))
420-
switch result {
421-
case .timedOut:
422-
expectFalse(true, "Timeout when awaiting finished state")
423-
default: break
424-
}
425-
}
426-
427-
tests.test("cancellation behavior of value emitted in handler throwing") {
428-
let ready = DispatchSemaphore(value: 0)
429-
let done = DispatchSemaphore(value: 0)
430-
let task = detach {
431-
let series = AsyncThrowingStream(String.self) { continuation in
432-
continuation.onTermination = { @Sendable _ in continuation.yield("Hit cancel") }
433-
}
434-
ready.signal()
435-
var iterator = series.makeAsyncIterator()
436-
do {
437-
let first = try await iterator.next()
438-
expectEqual(first, "Hit cancel")
439-
let second = try await iterator.next()
440-
expectEqual(second, nil)
441-
} catch {
442-
expectUnreachable("unexpected error thrown")
443-
}
444-
done.signal()
445-
}
446-
ready.wait()
447-
task.cancel()
448-
let result = done.wait(timeout: DispatchTime(uptimeNanoseconds: DispatchTime.now().uptimeNanoseconds + 1_000_000_000))
449-
switch result {
450-
case .timedOut:
451-
expectFalse(true, "Timeout when awaiting finished state")
452-
default: break
453-
}
454-
}
455-
456402
await runAllTestsAsync()
457403
}
458404
}

0 commit comments

Comments
 (0)