Repository navigation
Add discover_xctests to swift_test for Swift Testing-only targets - #1980
Closed
andyf-canva wants to merge 1 commit into
Closed
andyf-canva wants to merge 1 commit into
andyf-canva wants to merge 1 commit into
Conversation
`swift_test` with `discover_tests = True` always extracts symbol graphs on non-Apple platforms so the test discoverer can find XCTest-style tests, even when a target contains only Swift Testing `@Test` functions. Swift Testing discovers its tests at run time, so for those targets the extraction is wasted work. It can also fail outright: a module compiled with `-cxx-interoperability-mode=default` against libstdc++ cannot be loaded by `swift-symbolgraph-extract` on Linux, so the whole test target fails to build. Add a `discover_xctests` attribute (default `True`). Setting it to `False` skips the owner symbol graph extraction, passes a new `--swift-testing-only` flag to the test discoverer, and generates a runner that only runs Swift Testing tests. The attribute has no effect when `discover_tests` is `False`. Add passing and failing Swift Testing-only fixtures and shell tests, and regenerate `doc/rules.md`.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On non-Apple platforms,
swift_testwithdiscover_tests = Truealways extracts symbol graphs for the owner module and its direct deps so the test discoverer can find XCTest-style classes and methods, even when the target only contains Swift Testing@Testfunctions, which are discovered at run time. Besides being unneeded work, the extraction can fail outright:swift-symbolgraph-extractcannot currently load a module compiled with-cxx-interoperability-mode=defaultagainst libstdc++ on Linux (cannot load underlying module for 'CxxStdlib', fix proposed in swiftlang/swift#93696), so any Swift Testing target that depends on such a module fails to build even thoughswiftccompiles it. The only workaround today isdiscover_tests = Falseand a hand-writtenmainthat calls into Swift Testing.Add a
discover_xctestsattribute toswift_test(defaultTrue, so existing targets are unchanged). When it isFalseanddiscover_testsisTrue, the rule skips the owner symbol graph extraction and dep symbol graph collection, passes a new--swift-testing-onlyflag to the test discoverer with no symbol graph inputs or--module-outputs, and the generated runner keeps the same@mainshape but omits theXCTestRunner.run(__allDiscoveredXCTests())block. The attribute has no effect whendiscover_tests = False.Adds passing and failing Swift Testing-only fixtures and shell tests next to the existing Swift Testing ones, and regenerates
doc/rules.md. Verified on Linux (Swift 6.4, remote execution) with three Swift Testing-only targets that depend on a C++-interop module: withdiscover_xctests = Falsethe symbol graph actions disappear from the build and all three pass.