Skip to content

Commit

Permalink
Extend async test timeouts to prevent flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle authored Nov 1, 2023
1 parent 38a7d91 commit ffb1b26
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_app/AsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class AsyncTests : XCTestCase {
public func testAwaitAlreadyCompleted() throws {
let asyncOperation = AsyncMethods.getCompletedAsync(42)!
XCTAssertEqual(asyncOperation.status, .completed)
let result = try asyncBlock(timeout: 0.1) { try await asyncOperation.get() }
let result = try asyncBlock(timeout: 1) { try await asyncOperation.get() }
XCTAssertEqual(result, 42)
}

public func testAwaitAlreadyFailed() throws {
let asyncOperation = AsyncMethods.getCompletedWithErrorAsync(E_LAYOUTCYCLE)!
XCTAssertEqual(asyncOperation.status, .error)
do {
_ = try asyncBlock(timeout: 0.1) { try await asyncOperation.get() }
_ = try asyncBlock(timeout: 1) { try await asyncOperation.get() }
XCTFail("Expected an error to be thrown")
} catch let error as test_component.Error {
XCTAssertEqual(error.hr, E_LAYOUTCYCLE)
Expand All @@ -25,7 +25,7 @@ class AsyncTests : XCTestCase {
public func testAwaitCompletionWithSuspension() throws {
let asyncOperation = AsyncMethods.getPendingAsync()!
runAfter(delay: 0.05) { try? asyncOperation.complete(42) }
let result = try asyncBlock(timeout: 0.1) { try await asyncOperation.get() }
let result = try asyncBlock(timeout: 1) { try await asyncOperation.get() }
XCTAssertEqual(asyncOperation.status, .completed)
XCTAssertEqual(result, 42)
}
Expand All @@ -34,7 +34,7 @@ class AsyncTests : XCTestCase {
let asyncOperation = AsyncMethods.getPendingAsync()!
runAfter(delay: 0.05) { try? asyncOperation.completeWithError(E_LAYOUTCYCLE) }
do {
_ = try asyncBlock(timeout: 0.1) { try await asyncOperation.get() }
_ = try asyncBlock(timeout: 1) { try await asyncOperation.get() }
XCTFail("Expected an error to be thrown")
} catch let error as test_component.Error {
XCTAssertEqual(error.hr, E_LAYOUTCYCLE)
Expand Down

0 comments on commit ffb1b26

Please sign in to comment.