Skip to content

[Concurrency] Remove some tests that are inherently race conditions for AsyncStream #38083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions test/Concurrency/Runtime/async_stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,60 +406,6 @@ var tests = TestSuite("AsyncStream")
expectTrue(expectation.fulfilled)
}

tests.test("cancellation behavior of value emitted in handler") {
let ready = DispatchSemaphore(value: 0)
let done = DispatchSemaphore(value: 0)
let task = detach {
let series = AsyncStream(String.self) { continuation in
continuation.onTermination = { @Sendable _ in continuation.yield("Hit cancel") }
}
ready.signal()
var iterator = series.makeAsyncIterator()
let first = await iterator.next()
expectEqual(first, "Hit cancel")
let second = await iterator.next()
expectEqual(second, nil)
done.signal()
}
ready.wait()
task.cancel()
let result = done.wait(timeout: DispatchTime(uptimeNanoseconds: DispatchTime.now().uptimeNanoseconds + 1_000_000_000))
switch result {
case .timedOut:
expectFalse(true, "Timeout when awaiting finished state")
default: break
}
}

tests.test("cancellation behavior of value emitted in handler throwing") {
let ready = DispatchSemaphore(value: 0)
let done = DispatchSemaphore(value: 0)
let task = detach {
let series = AsyncThrowingStream(String.self) { continuation in
continuation.onTermination = { @Sendable _ in continuation.yield("Hit cancel") }
}
ready.signal()
var iterator = series.makeAsyncIterator()
do {
let first = try await iterator.next()
expectEqual(first, "Hit cancel")
let second = try await iterator.next()
expectEqual(second, nil)
} catch {
expectUnreachable("unexpected error thrown")
}
done.signal()
}
ready.wait()
task.cancel()
let result = done.wait(timeout: DispatchTime(uptimeNanoseconds: DispatchTime.now().uptimeNanoseconds + 1_000_000_000))
switch result {
case .timedOut:
expectFalse(true, "Timeout when awaiting finished state")
default: break
}
}

await runAllTestsAsync()
}
}
Expand Down