Swift test --parallel failing when installing swift-format

I seem to be failing the test cases for the swift-format installation and I'm not sure why. The test cases that fail seem to exit with exit code 4. The swift-format version is from the swift-5.4 branch on Github

Are you building it with Swift 5.4 (or Xcode 12.5 selected)? The swift-format branches seem to be tightly coupled with their corresponding Swift releases.

My swift version is 5.4.2 and Xcode version is 12.5.1

Signal 4 is SIGILL, "illegal instruction". Are you perhaps running your shell (and swift test) in Rosetta on Apple Silicon? I would expect that to work, but SIGILL implies the compiled code is invalid.

I am not running Rosetta on Apple Silicon. Something I forgot to mention is that I sometimes get a different error message when running swift test. For example, the following screenshot contains a slightly different error message from running swift test --parallel again.

Could be this:

I tried reinstalling swift-format to run swift test without the --parallel flag. The test cases are still exiting with signal 4, but this time there are helpful error messages. It seems like one of the problems may be an incompatible SwiftSyntax library?

Ah, yeah, that's the "tightly coupled" bit I mentioned. Check that xcode-select -p lists the version of Xcode that corresponds to Swift version you expect to be invoking. That Swift version should match the branch of swift-format in your project. If you need to target multiple Swift versions, you can do something like this in your Package.swift:

#if compiler(>=5.4)
    package.dependencies += [
        .package(url: "https://github.com/apple/swift-format", .branch("swift-5.4-branch"))
#elseif compiler(>=5.3)
    package.dependencies += [
        .package(url: "https://github.com/apple/swift-format", .branch("swift-5.3-branch"))

...and then swift run swift-format ....

If you're installing swift-format from Homebrew or another package manager, you'll have to be sure to invoke a version of Swift that corresponds to the swift-format version from that package manager.

Terms of Service

Privacy Policy

Cookie Policy