Compiler crash during setup of Swift Testing

I've read the documentation explainer here. But when I try to compile I'm having a compiler crash

I have the following file structure:
6_AddTests/
├── CMakeLists.txt
├── exe/
│ ├── CMakeLists.txt
│ └── main.swift
├── lib/
├── CMakeLists.txt
│ └── sum.swift
└── tests/
├── CMakeLists.txt
└── test_sum.swift

sum.swift:

public func sum(_ a: Int, _ b: Int) -> Int {
    return a + b
}

tests/CMakeLists.txt

add_executable(SumTests test_sum.swift)

set_target_properties(SumTests PROPERTIES
  SUFFIX .swift-testing
)

target_link_libraries(SumTests
    PRIVATE
      sum
      Testing
)

test_sum.swift

import Testing
import sum

@main
struct Runner {
    static func main() async {
        print("sum(1, 2) = \(sum(1, 2))")
    }
}

I'm compiling with Clang 16. The error is following:

[build] 1.	Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
[build] 2.	Compiling with effective version 5.10
[build] 3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for TestingMacros)
[build] 4.	While running pass #361 SILFunctionTransform "OwnershipModelEliminator" on SILFunction "@$s11SwiftSyntax0B10IdentifierV2eeoiySbAC_ACtFZ".
[build]  for <<debugloc at "<compiler-generated>":0:0>> #0 0x0000000107b6b0fc (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10596f0fc)
[build]  #1 0x0000000107b69350 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10596d350)
[build]  #2 0x0000000107b6b6c8 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10596f6c8)
[build]  #3 0x000000019b68c184 (/usr/lib/system/libsystem_platform.dylib+0x180484184)
[build]  #4 0x000000010334d9dc (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1011519dc)
[build]  #5 0x000000010334bb98 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10114fb98)
[build]  #6 0x0000000103357554 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10115b554)
[build]  #7 0x0000000103350d74 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x101154d74)
[build]  #8 0x000000010338d084 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x101191084)
[build]  #9 0x00000001033709e8 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1011749e8)
[build] #10 0x00000001033738bc (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1011778bc)
[build] #11 0x00000001028eb1ac (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1006ef1ac)
[build] #12 0x0000000102515d68 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100319d68)
[build] #13 0x0000000102514f74 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100318f74)
[build] #14 0x0000000102518228 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10031c228)
[build] #15 0x0000000102516f58 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10031af58)
[build] #16 0x000000010249e01c (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1002a201c)
[build] #17 0x000000019b2d4274 
[build] ninja: build stopped: subcommand failed.
[build] ninja: build stopped: subcommand failed.

Any ideas?

This appears to be a crash in the Swift compiler. Would you please open a GitHub issue against the Swift repository and include this information? Thanks!

In the mean time, if you are using Xcode or swift test, you don't need to build Swift Testing from source—it's available in your test targets automatically.

Thanks, I'll add it.

I'm not using Xcode since all of my development was in VS code with Cmake & ninja setup and it worked well. I'll try later to generate Xcode project and see how it's going to be.

I just followed the steps to fetch swift-testing and I thought that this is the way to go.

Those instructions are for developers building bespoke toolchains (and we need to update them, I think.) You shouldn't need to worry about them if you are using a Swift 6 toolchain you've downloaded from swift.org since Swift Testing is included in them.

Finally I wasn't able to use swift Testing for now in CMake. However, I've continued using xctest because I just wanted to run tests without generating Xcode project.

I'm leaving a solution to what I've tried to do in order someone want to do similar thing.

I've done that by using a CMake module from here called FindSwiftXCTest.cmake.

Here you can check full implementation how I've done it.