Skip to content

[6.0] Build one test product for both Swift Testing and XCTest (with Swift Testing enabled by default.) #7794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jul 18, 2024

Explanation: Refactors the previously-experimental Swift Testing support logic so that only a single build product is produced when using both XCTest and Swift Testing, and detection of Swift Testing usage is no longer needed at compile time.
Scope: Implementation of Swift Testing/SwiftPM integration; touches mostly swift test but affects swift build and swift package init as well.
Issue: rdar://120864035
Original PR: #7777, #7789, #7796
Risk: Moderate—refactors how we build and run tests.
Testing: Existing test coverage in the package as well as test coverage in the Swift Testing package; additional integration testing will be added once Swift Testing is in the toolchain.
Reviewer: @bnbarham @xedin @briancroom @dennisweissmann

grynspan and others added 2 commits July 18, 2024 13:37
This PR detects when a Swift Testing run returns `EXIT_NO_TESTS_FOUND`
and treats it as a successful test run.

This change handles the change from
swiftlang/swift-testing#536. Separately, the
refactor in #7766 stops Swift Package Manager from reporting `"No
matching test cases were run"` when XCTest has no tests matching passed
`--filter` arguments. A third PR after these two have been merged will
restore that functionality by collating results from both XCTest and
Swift Testing.

> [!NOTE]
> Test coverage can be added after Swift Testing is in the Swift
toolchain.

This change partially resolves rdar://131704587.
…Testing enabled by default.) (#7789)

This PR refactors the previously-experimental Swift Testing support
logic so that only a single build product is produced when using both
XCTest and Swift Testing, and detection of Swift Testing usage is no
longer needed at compile time.

On macOS, Xcode 16 is responsible for hosting Swift Testing content, so
additional changes may be needed in Xcode to support this refactoring.
Such changes are beyond the purview of the Swift open source project.

This PR includes changes from the previous PRs numbered #7766, #7783,

Resolves rdar://120864035.

Co-authored-by: Pavel Yaskevich <xedin@apache.org>
@grynspan grynspan added enhancement build system Changes to interactions with build systems performance Performance optimizations and improvements swift test Changes impacting `swift test` tool swift build Changes impacting `swift build` swift package init Package templates command changes command-line interface swift 6.0 Related to Swift 6.0 release branch labels Jul 18, 2024
@grynspan grynspan self-assigned this Jul 18, 2024
@grynspan grynspan requested a review from a team as a code owner July 18, 2024 17:55
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

Build failures right now are due to missing ICU content.

@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

Need #7796 too.

…7796)

This PR forces Swift Testing to write its xUnit output to a different
path from what the user specifies.

In the future, we should have the two testing libraries collate their
XML output into a single file, but that requires the ability to parse
and reformat XML output and that's a little beyond the capabilities of
this feature right now. Since we expect most uses of xUnit output right
now are existing ones with existing XCTest-based tests, moving Swift
Testing aside seems like the right call.

(If XCTest is explicitly disabled, the exact specified path is used.)
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan grynspan merged commit 547f649 into release/6.0 Jul 19, 2024
5 checks passed
@grynspan grynspan deleted the jgrynspan/one-test-product-two-libraries-take-2-6.0 branch July 19, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Changes to interactions with build systems command-line interface enhancement performance Performance optimizations and improvements swift build Changes impacting `swift build` swift package init Package templates command changes swift test Changes impacting `swift test` tool swift 6.0 Related to Swift 6.0 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants