From a69be480668e839448fd18622ee116cf6b186e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 2 May 2020 15:13:02 +0200 Subject: [PATCH] Give more time to tests --- .../GRDBTests/ValueObservationRecorder.swift | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Tests/GRDBTests/ValueObservationRecorder.swift b/Tests/GRDBTests/ValueObservationRecorder.swift index 2b308911e..d6dc99d18 100644 --- a/Tests/GRDBTests/ValueObservationRecorder.swift +++ b/Tests/GRDBTests/ValueObservationRecorder.swift @@ -378,6 +378,13 @@ extension GRDBTestCase { throws where Reducer.Value: Equatable { + #if SQLITE_HAS_CODEC || GRDBCUSTOMSQLITE + // debug SQLite builds can be *very* slow + let timeout: TimeInterval = 1 + #else + let timeout: TimeInterval = 0.3 + #endif + func test( observation: ValueObservation, scheduling scheduler: ValueObservationScheduler, @@ -404,7 +411,7 @@ extension GRDBTestCase { try writer.writeWithoutTransaction(recordedUpdates) let expectation = recorder.next(expectedValues.count) - let values = try wait(for: expectation, timeout: 0.3) + let values = try wait(for: expectation, timeout: timeout) XCTAssertEqual( values, expectedValues, "\(#function), \(writer), \(scheduler)", file: file, line: line) @@ -434,7 +441,7 @@ extension GRDBTestCase { } let expectation = recorder.next(expectedValues.count) - let values = try wait(for: expectation, timeout: 0.3) + let values = try wait(for: expectation, timeout: timeout) XCTAssertEqual( values, expectedValues, "\(#function), \(writer), \(scheduler)", file: file, line: line) @@ -465,19 +472,14 @@ extension GRDBTestCase { if waitForLast { // Optimization! let expectation = recorder.prefix(until: { $0 == lastExpectedValue } ) - recordedValues = try wait(for: expectation, timeout: 1) + recordedValues = try wait(for: expectation, timeout: timeout) } else { // Slow! assertionFailure("Please rewrite your test, because it is too slow: make sure the last expected value is unique.") let expectation = recorder .prefix(expectedValues.count + 2 /* pool may perform double initial fetch */) .inverted - #if SQLITE_HAS_CODEC || GRDBCUSTOMSQLITE - // debug SQLite builds can be *very* slow - recordedValues = try wait(for: expectation, timeout: 1) - #else - recordedValues = try wait(for: expectation, timeout: 0.3) - #endif + recordedValues = try wait(for: expectation, timeout: timeout) } if scheduler.immediateInitialValue() { @@ -519,19 +521,14 @@ extension GRDBTestCase { if waitForLast { // Optimization! let expectation = recorder.prefix(until: { $0 == lastExpectedValue } ) - recordedValues = try wait(for: expectation, timeout: 1) + recordedValues = try wait(for: expectation, timeout: timeout) } else { // Slow! assertionFailure("Please rewrite your test, because it is too slow: make sure the last expected value is unique.") let expectation = recorder .prefix(expectedValues.count + 2 /* pool may perform double initial fetch */) .inverted - #if SQLITE_HAS_CODEC || GRDBCUSTOMSQLITE - // debug SQLite builds can be *very* slow - recordedValues = try wait(for: expectation, timeout: 1) - #else - recordedValues = try wait(for: expectation, timeout: 0.3) - #endif + recordedValues = try wait(for: expectation, timeout: timeout) } XCTAssertEqual(recordedValues.first, expectedValues.first) @@ -598,6 +595,13 @@ extension GRDBTestCase { line: UInt = #line) throws { + #if SQLITE_HAS_CODEC || GRDBCUSTOMSQLITE + // debug SQLite builds can be *very* slow + let timeout: TimeInterval = 1 + #else + let timeout: TimeInterval = 0.3 + #endif + func test( observation: ValueObservation, scheduling scheduler: ValueObservationScheduler, @@ -611,7 +615,7 @@ extension GRDBTestCase { scheduling: scheduler, onError: { _ in testErrorDispatching() }) - let (_, error) = try wait(for: recorder.failure(), timeout: 0.3) + let (_, error) = try wait(for: recorder.failure(), timeout: timeout) if let error = error as? Failure { try testFailure(error, writer) } else {