Skip to content

Commit 7ccc1b0

Browse files
authored
Merge pull request #38083 from phausler/phausler/async_stream_cancel_failure
[Concurrency] Remove some tests that are inherently race conditions for AsyncStream
2 parents 0572b35 + b813e5a commit 7ccc1b0

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
@@ -406,60 +406,6 @@ var tests = TestSuite("AsyncStream")
406406
expectTrue(expectation.fulfilled)
407407
}
408408

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

0 commit comments

Comments
 (0)