Nimble: Trouble with testing fatalError()

Created on 30 Dec 2020  路  4Comments  路  Source: Quick/Nimble

  • [ ] I have read CONTRIBUTING and have done my best to follow them.

What did you do?

expect { sut.getText() }.to(throwAssertion())
expect { try sut.getText() }.to(throwAssertion())

What did you expect to happen?

I expected it to test if the fatal error was thrown from my method getText() { fatalError("Mistake.") }

What actually happened instead?

fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " + "Objective-C (e.g. macOS, iPhone 5s or later simulators). You can silence this error " + "by placing the test case inside an #if arch(x86_64) or canImport(Darwin) conditional statement")

Could be an issue with using the M1?

Environment

List the software versions you're using:

  • Quick: (3.0.0)
  • Nimble: (9.0.0)
  • Xcode Version: Version 12.2 (12B45b) (Open Xcode; In menubar: Xcode > About Xcode)
  • Swift Version: 5.0 (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.)

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Cocoapods: *1.10.0 (Use pod --version in Terminal)
  • Carthage: ?.? (Use carthage version in Terminal)
  • Swift Package Manager ?.?.? (swiftpm-???) (Use swift build --version in Terminal)

Project that demonstrates the issue

Please link to a project we can download that reproduces the issue. Feel free
to delete this section if it's not relevant to the issue (eg - feature request).

The project should be short, self-contained, and correct example.

Most helpful comment

Yep it's definitely an issue with the M1

All 4 comments

Yep it's definitely an issue with the M1

Is there any solution for this?

Problem lies in the ThrowAssertion matcher which btw also catches assertions, not only fatalError.

https://github.com/Quick/Nimble/blob/e4aa2014de13b90b06eaf183c67be3e390e927da/Sources/Nimble/Matchers/ThrowAssertion.swift#L9

If I remove the platform check arch(x86_64) and edit the scheme to _not_ debug executable during tests, it works for me. The latter is sadly required as Xcode's debugger catches the assertions anyway.

Verified to work on M1 with Xcode 12.4 on arm64 Simulator.

I'd suggest to rename this issue to "Apple Silicon / M1 Support" or something like that. Beside ThrowAssertion requiring an update to #if canImport(Darwin) && (arch(x86_64) || arch(arm64)) the Cwl Library is not arm64 compatible.

See the open issue in the other repo: https://github.com/mattgallagher/CwlPreconditionTesting/issues/21

Was this page helpful?
0 / 5 - 0 ratings