swift-testing icon indicating copy to clipboard operation
swift-testing copied to clipboard

[cmake] Build swift-testing with CMake.

Open jeffdav opened this issue 1 year ago • 10 comments

Add files needed to build swift-testing with CMake.

Motivation:

Being able to build with CMake is useful in many scenarios. The immediate need is to bring swift-testing to Windows. To do so we need to support a non-SPM path to allow building targets that would otherwise hit the export symbol limit on Windows.

Modifications:

  • Added CMake files to build Testing, TestingInternal, and TestingMacros.
  • Build TestingMacros as an ExternalProject targeting the build machine.
  • Add SwiftTesting_GenerateDerivedSources which generates a runner-swift-testing.swift and returns a variable that allows consumers to compile it with their sources.

Result:

  • Can build swift-testing with CMake. Example command lines:
cmake -S . -B b -G Ninja -D CMAKE_CXX_COMPILER=clang
cmake --build .\b
  • Example diff that converts swift-webdriver to use swift-testing via CMake.

Checklist:

  • [X] Code and documentation should follow the style of the Style Guide.
  • [X] If public symbols are renamed or modified, DocC references should be updated.

jeffdav avatar Apr 30 '24 23:04 jeffdav

Thank you @jeffdav! Appreciate the helpful contribution. I have several comments so far and will take a second pass tomorrow

stmontgomery avatar May 01 '24 02:05 stmontgomery

Open question: how do we test this change?

grynspan avatar May 01 '24 12:05 grynspan

@jeffdav Could we ask you to just push additional commits so it's easier for us to see incremental changes? We'll squash the whole thing when we merge the PR. Thanks!

grynspan avatar May 01 '24 22:05 grynspan

No problem. I wasn't sure what the right thing to do was. I'd honestly prefer incremental diffs. :)

jeffdav avatar May 01 '24 22:05 jeffdav

Oh, but github does have a little "compare" link next to each force-push, which I hadn't realized.

jeffdav avatar May 01 '24 22:05 jeffdav

Something else for you to consider: we should have instructions somewhere (perhaps in a dedicated .md file in Documentation/) showing how to build swift-testing from source using CMake.

grynspan avatar May 01 '24 22:05 grynspan

Something else for you to consider: we should have instructions somewhere (perhaps in a dedicated .md file in Documentation/) showing how to build swift-testing from source using CMake.

Added. I'd love feedback on the documentation (consider this a 1st draft).

jeffdav avatar May 02 '24 19:05 jeffdav

Holding off on approval because I am not in a position to audit the CMake bits, not myself understanding anything about CMake. @etcwilde would you please review?

grynspan avatar May 09 '24 16:05 grynspan

@swift-ci please test

grynspan avatar May 09 '24 16:05 grynspan

@grynspan any further concerns on your side?

jeffdav avatar May 16 '24 19:05 jeffdav

Nope, I defer to @etcwilde here.

(FYI we don't use Swift's C++ interop feature, so its lack of support for exceptions doesn't make a difference to us. However, we also don't throw any exceptions or intend to catch any, so it's moot.)

grynspan avatar May 16 '24 20:05 grynspan

Oh—please update the file lists before merging. There are a number of new files added since you opened this PR.

grynspan avatar May 16 '24 20:05 grynspan

Oh—please update the file lists before merging. There are a number of new files added since you opened this PR.

Done!

jeffdav avatar May 16 '24 23:05 jeffdav

@swift-ci please test

grynspan avatar May 18 '24 19:05 grynspan

@jeffdav I know you folks obviously work with Windows. The Windows failure we're seeing is a compiler bug unrelated to your PR. If you're comfortable with merging the PR despite the failure, we can proceed. (I'm unsure if you can see a merge button—if not, ping me and I'll do it.)

grynspan avatar May 19 '24 13:05 grynspan

@jeffdav I know you folks obviously work with Windows. The Windows failure we're seeing is a compiler bug unrelated to your PR. If you're comfortable with merging the PR despite the failure, we can proceed. (I'm unsure if you can see a merge button—if not, ping me and I'll do it.)

Yeah, I'm familiar with that compiler bug for other reasons. :)

jeffdav avatar May 19 '24 22:05 jeffdav

@grynspan Thanks for your help! I don't have a merge button.

jeffdav avatar May 20 '24 05:05 jeffdav

@swift-ci please test

grynspan avatar May 20 '24 11:05 grynspan