Skip to content
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

Reduce the overall warnings from tests #274

Merged
merged 3 commits into from
Jun 23, 2023
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
4 changes: 4 additions & 0 deletions Sources/AsyncSequenceValidation/Clock.swift
Original file line number Diff line number Diff line change
@@ -132,3 +132,7 @@ extension AsyncSequenceValidationDiagram.Clock: TestClock { }

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
extension AsyncSequenceValidationDiagram.Clock: Clock { }

// placeholders to avoid warnings
extension AsyncSequenceValidationDiagram.Clock.Instant: Hashable { }
extension AsyncSequenceValidationDiagram.Clock.Instant: Comparable { }
6 changes: 6 additions & 0 deletions Sources/AsyncSequenceValidation/Test.swift
Original file line number Diff line number Diff line change
@@ -68,6 +68,12 @@ extension AsyncSequenceValidationDiagram {

struct Context {
final class ClockExecutor: SerialExecutor {
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
func enqueue(_ job: __owned ExecutorJob) {
job.runSynchronously(on: asUnownedSerialExecutor())
}

@available(*, deprecated) // known deprecation warning
func enqueue(_ job: UnownedJob) {
job._runSynchronously(on: asUnownedSerialExecutor())
}
5 changes: 3 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift
Original file line number Diff line number Diff line change
@@ -88,10 +88,11 @@ final class TestAdjacentPairs: XCTestCase {
}

// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)

await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestBuffer.swift
Original file line number Diff line number Diff line change
@@ -190,13 +190,13 @@ final class TestBuffer: XCTestCase {
finished.fulfill()
}
// ensure the task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)

// When
task.cancel()

// Then
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_given_a_base_sequence_when_buffering_with_bounded_then_the_buffer_is_filled_in_and_suspends() async {
@@ -310,13 +310,13 @@ final class TestBuffer: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)

// When
task.cancel()

// Then
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_given_a_base_sequence_when_bounded_with_limit_0_then_the_policy_is_transparent() async {
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift
Original file line number Diff line number Diff line change
@@ -199,10 +199,10 @@ final class TestBufferedByteIterator: XCTestCase {
}
}
}
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestChain.swift
Original file line number Diff line number Diff line change
@@ -87,13 +87,13 @@ final class TestChain2: XCTestCase {
}

// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)

// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}

@@ -192,12 +192,12 @@ final class TestChain3: XCTestCase {
}

// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)

// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
2 changes: 1 addition & 1 deletion Tests/AsyncAlgorithmsTests/TestChannel.swift
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ final class TestChannel: XCTestCase {
task1.cancel()

// Then: the first sending operation is resumed
wait(for: [send1IsResumed], timeout: 1.0)
await fulfillment(of: [send1IsResumed], timeout: 1.0)

// When: collecting elements
var iterator = sut.makeAsyncIterator()
18 changes: 9 additions & 9 deletions Tests/AsyncAlgorithmsTests/TestCombineLatest.swift
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ final class TestCombineLatest2: XCTestCase {
value = await validator.validate()
XCTAssertEqual(value, [(1, "a"), (2, "a"), (2, "b"), (3, "b"), (3, "c")])

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (2, "a"), (2, "b"), (3, "b"), (3, "c")])
}
@@ -126,7 +126,7 @@ final class TestCombineLatest2: XCTestCase {
value = await validator.validate()
XCTAssertEqual(value, [(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c")])

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c")])
}
@@ -168,7 +168,7 @@ final class TestCombineLatest2: XCTestCase {
value = await validator.validate()
XCTAssertEqual(value, [(1, "a"), (2, "a"), (3, "a"), (3, "b"), (3, "c")])

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (2, "a"), (3, "a"), (3, "b"), (3, "c")])
}
@@ -210,7 +210,7 @@ final class TestCombineLatest2: XCTestCase {
value = await validator.validate()
XCTAssertEqual(value, [(1, "a"), (1, "b"), (1, "c"), (2, "c"), (3, "c")])

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (1, "b"), (1, "c"), (2, "c"), (3, "c")])
}
@@ -250,7 +250,7 @@ final class TestCombineLatest2: XCTestCase {

XCTAssertEqual(validator.failure as? Failure, Failure())

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (1, "b")])
}
@@ -290,7 +290,7 @@ final class TestCombineLatest2: XCTestCase {

XCTAssertEqual(validator.failure as? Failure, Failure())

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a"), (2, "a")])
}
@@ -312,11 +312,11 @@ final class TestCombineLatest2: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_combineLatest_when_cancelled() async {
@@ -389,7 +389,7 @@ final class TestCombineLatest3: XCTestCase {
value = await validator.validate()
XCTAssertEqual(value, [(1, "a", 4), (2, "a", 4), (2, "b", 4), (2, "b", 5), (3, "b", 5), (3, "c", 5), (3, "c", 6)])

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [(1, "a", 4), (2, "a", 4), (2, "b", 4), (2, "b", 5), (3, "b", 5), (3, "c", 5), (3, "c", 6)])
}
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestCompacted.swift
Original file line number Diff line number Diff line change
@@ -83,10 +83,10 @@ final class TestCompacted: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestJoin.swift
Original file line number Diff line number Diff line change
@@ -122,11 +122,11 @@ final class TestJoinedBySeparator: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}

@@ -206,10 +206,10 @@ final class TestJoined: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestLazy.swift
Original file line number Diff line number Diff line change
@@ -121,12 +121,12 @@ final class TestLazy: XCTestCase {
}

// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)

// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
6 changes: 3 additions & 3 deletions Tests/AsyncAlgorithmsTests/TestManualClock.swift
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ final class TestManualClock: XCTestCase {
clock.advance()
XCTAssertFalse(state.withCriticalRegion { $0 })
clock.advance()
wait(for: [afterSleep], timeout: 1.0)
await fulfillment(of: [afterSleep], timeout: 1.0)
XCTAssertTrue(state.withCriticalRegion { $0 })
}

@@ -51,7 +51,7 @@ final class TestManualClock: XCTestCase {
XCTAssertFalse(state.withCriticalRegion { $0 })
clock.advance()
task.cancel()
wait(for: [afterSleep], timeout: 1.0)
await fulfillment(of: [afterSleep], timeout: 1.0)
XCTAssertTrue(state.withCriticalRegion { $0 })
XCTAssertTrue(failure.withCriticalRegion { $0 is CancellationError })
}
@@ -73,7 +73,7 @@ final class TestManualClock: XCTestCase {
}
XCTAssertFalse(state.withCriticalRegion { $0 })
task.cancel()
wait(for: [afterSleep], timeout: 1.0)
await fulfillment(of: [afterSleep], timeout: 1.0)
XCTAssertTrue(state.withCriticalRegion { $0 })
XCTAssertTrue(failure.withCriticalRegion { $0 is CancellationError })
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestMerge.swift
Original file line number Diff line number Diff line change
@@ -185,11 +185,11 @@ final class TestMerge2: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_merge_when_cancelled() async {
@@ -509,11 +509,11 @@ final class TestMerge3: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

// MARK: - IteratorInitialized
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestReductions.swift
Original file line number Diff line number Diff line change
@@ -217,10 +217,10 @@ final class TestReductions: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift
Original file line number Diff line number Diff line change
@@ -95,10 +95,10 @@ final class TestRemoveDuplicates: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}
2 changes: 1 addition & 1 deletion Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ final class TestThrowingChannel: XCTestCase {
task1.cancel()

// Then: the first sending operation is resumed
wait(for: [send1IsResumed], timeout: 1.0)
await fulfillment(of: [send1IsResumed], timeout: 1.0)

// When: collecting elements
var iterator = sut.makeAsyncIterator()
20 changes: 10 additions & 10 deletions Tests/AsyncAlgorithmsTests/TestValidator.swift
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ final class TestValidator: XCTestCase {
}
XCTAssertFalse(state.withCriticalRegion { $0 })
gate.open()
wait(for: [entered], timeout: 1.0)
await fulfillment(of: [entered], timeout: 1.0)
XCTAssertTrue(state.withCriticalRegion { $0 })
}

@@ -52,18 +52,18 @@ final class TestValidator: XCTestCase {
}
finished.fulfill()
}
wait(for: [started], timeout: 1.0)
await fulfillment(of: [started], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [])
gated.advance()
wait(for: [expectations[0]], timeout: 1.0)
await fulfillment(of: [expectations[0]], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [1])
gated.advance()
wait(for: [expectations[1]], timeout: 1.0)
await fulfillment(of: [expectations[1]], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [1, 2])
gated.advance()
wait(for: [expectations[2]], timeout: 1.0)
await fulfillment(of: [expectations[2]], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [1, 2, 3])
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_gatedSequence_throwing() async {
@@ -93,14 +93,14 @@ final class TestValidator: XCTestCase {
}
finished.fulfill()
}
wait(for: [started], timeout: 1.0)
await fulfillment(of: [started], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [])
gated.advance()
wait(for: [expectations[0]], timeout: 1.0)
await fulfillment(of: [expectations[0]], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [1])
gated.advance()
XCTAssertEqual(state.withCriticalRegion { $0 }, [1])
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
XCTAssertEqual(state.withCriticalRegion { $0 }, [1])
XCTAssertEqual(failure.withCriticalRegion { $0 as? Failure }, Failure())
}
@@ -131,7 +131,7 @@ final class TestValidator: XCTestCase {
XCTAssertEqual(value, [2, 3, 4])
a.advance()

wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
value = validator.current
XCTAssertEqual(value, [2, 3, 4])
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestZip.swift
Original file line number Diff line number Diff line change
@@ -152,11 +152,11 @@ final class TestZip2: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}

func test_zip_when_cancelled() async {
@@ -370,10 +370,10 @@ final class TestZip3: XCTestCase {
finished.fulfill()
}
// ensure the other task actually starts
wait(for: [iterated], timeout: 1.0)
await fulfillment(of: [iterated], timeout: 1.0)
// cancellation should ensure the loop finishes
// without regards to the remaining underlying sequence
task.cancel()
wait(for: [finished], timeout: 1.0)
await fulfillment(of: [finished], timeout: 1.0)
}
}