Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
younata committed Sep 10, 2024
1 parent f3f7153 commit 638c2f0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,26 @@ public class NMBWait: NSObject {
case .incomplete: internalError("Reached .incomplete state for waitUntil(...).")
case .blockedRunLoop:
fail(blockedRunLoopErrorMessageFor("-waitUntil()", leeway: leeway),
file: file, line: line)
fileID: fileID, file: file, line: line, column: column)
case .timedOut:
fail("Waited more than \(timeout.description)", file: file, line: line)
fail("Waited more than \(timeout.description)",
fileID: fileID, file: file, line: line, column: column)
case let .raisedException(exception):
fail("Unexpected exception raised: \(exception)")
fail("Unexpected exception raised: \(exception)",
fileID: fileID, file: file, line: line, column: column
)
case let .errorThrown(error):
fail("Unexpected error thrown: \(error)")
fail("Unexpected error thrown: \(error)",
fileID: fileID, file: file, line: line, column: column
)
case .completed(.exception(let exception)):
fail("Unexpected exception raised: \(exception)")
fail("Unexpected exception raised: \(exception)",
fileID: fileID, file: file, line: line, column: column
)
case .completed(.error(let error)):
fail("Unexpected error thrown: \(error)")
fail("Unexpected error thrown: \(error)",
fileID: fileID, file: file, line: line, column: column
)
case .completed(.none): // success
break
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public func fail(_ message: String, fileID: String = #fileID, file: FileString =
}

/// Always fails the test.
public func fail(_ fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column) {
public func fail(fileID: String = #fileID, file: FileString = #filePath, line: UInt = #line, column: UInt = #column) {
fail("fail() always fails", location: SourceLocation(fileID: fileID, filePath: file, line: line, column: column))
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/NimbleTests/PollingTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ final class PollingTest: XCTestCase {
Unexpected exception raised: Nested async expectations are not allowed to avoid creating flaky tests.
The call to
\texpect(...).toEventually(...) at \(#file):\(referenceLine + 7)
\texpect(...).toEventually(...) at \(#file):\(referenceLine + 7):23
triggered this exception because
\twaitUntil(...) at \(#file):\(referenceLine + 1)
\twaitUntil(...) at \(#file):\(referenceLine + 1):34
is currently managing the main run loop.
"""
failsWithErrorMessage(msg) { // reference line
Expand Down

0 comments on commit 638c2f0

Please sign in to comment.