-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add swift-testing support to swift build --build-tests
#7377
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
Conversation
This PR generalizes the enable/disable XCTest/swift-testing options from `swift test` and `swift package init` and adds them to `swift build --build-tests` so that it is possible to build all test content without actually running the tests. If neither flag is specified, the default test content is built (always XCTest, and swift-testing if it's a dependency, same as `swift test`.) I don't have unit tests for this work because SwiftPM cannot currently reference or link to swift-testing in CI. I'm open to ideas here. Resolves #7375.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't claim to fully understand the code but it does look good to me. Thank you!!
swift build --build-tests
.swift build --build-tests
@@ -132,6 +148,20 @@ struct SharedOptions: ParsableArguments { | |||
// Default to disabled since swift-testing is experimental (opt-in.) | |||
return false | |||
} | |||
|
|||
/// Get the set of enabled testing libraries. | |||
func enabledTestingLibraries(swiftCommandState: SwiftCommandState) throws -> Set<BuildParameters.Testing.Library> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting nit: we avoid long lines for better readability in diff views and on devices that don't have huge screens.
func enabledTestingLibraries(swiftCommandState: SwiftCommandState) throws -> Set<BuildParameters.Testing.Library> { | |
func enabledTestingLibraries( | |
swiftCommandState: SwiftCommandState | |
) throws -> Set<BuildParameters.Testing.Library> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the cutoff you generally prefer? I can set my gutter to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have all of the formatting rules specified in the formatter config https://github.com/apple/swift-package-manager/blob/main/.swiftformat. Just run ./Utilities/soundness.sh
before committing and that will reformat changed files for you with that config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That script did not produce any diagnostics nor make any changes to my branch.
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a test case to prevent future regressions?
See the PR description. How would you implement it? |
@swift-ci please test |
@swift-ci please test Windows |
I think we need a new |
It looks like |
@swift-ci please test |
@swift-ci please test Windows |
I understand, this shouldn't be the reason to reduce our overall test coverage though. |
I don't believe I'm reducing it as this feature already does not have any test coverage, but maybe I'm misunderstanding? 🙂 |
I'd argue that right now the feature is untested (bad) but also not working (worse). Why don't we make the situation better by fixing it? Once this is merged (and therefore fixed) we can maybe team up to write at least some basic tests? |
That sounds like an excellent plan! |
It appears the lack of tests hurt us here: this pull broke I can reproduce the crash on linux x86_64 with the following commands, which work with the last Feb. 29 trunk snapshot before this pull:
|
) This PR generalizes the enable/disable XCTest/swift-testing options from `swift test` and `swift package init` and adds them to `swift build --build-tests` so that it is possible to build all test content without actually running the tests. If neither flag is specified, the default test content is built (always XCTest, and swift-testing if it's a dependency, same as `swift test`.) Resolves swiftlang#7375.
) This PR generalizes the enable/disable XCTest/swift-testing options from `swift test` and `swift package init` and adds them to `swift build --build-tests` so that it is possible to build all test content without actually running the tests. If neither flag is specified, the default test content is built (always XCTest, and swift-testing if it's a dependency, same as `swift test`.) Resolves swiftlang#7375.
This PR generalizes the enable/disable XCTest/swift-testing options from
swift test
andswift package init
and adds them toswift build --build-tests
so that it is possible to build all test content without actually running the tests. If neither flag is specified, the default test content is built (always XCTest, and swift-testing if it's a dependency, same asswift test
.)I don't have unit tests for this work because SwiftPM cannot currently reference or link to swift-testing in CI. I'm open to ideas here.
Resolves #7375.