Skip to content

Detect when Swift Testing returns EXIT_NO_TESTS_FOUND. #7777

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
merged 2 commits into from
Jul 15, 2024

Conversation

grynspan
Copy link
Contributor

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.

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.

This change partially resolves rdar://131704587.
@grynspan grynspan added bug swift test Changes impacting `swift test` tool labels Jul 14, 2024
@grynspan grynspan self-assigned this Jul 14, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test

success = success && testSuccess
results.append(testSuccess)
}
if results.contains(.failure) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything failed, the run failed. If anything passed and had matching tests, the run passed. If everything reported no matching tests, then there were no matching tests.


/// Executes and returns execution status. Prints test output on standard streams if requested
/// - Returns: Result of spawning and running the test process, and the output stream result
@_disfavoredOverload
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporarily disfavored until #7766 is in the build in order to preserve the semantics of surrounding code, at which point the overload that returns a Bool can be removed.

/// Because Swift Package Manager does not directly link to the testing library,
/// it duplicates the definition of this constant in its own source. Any changes
/// to this constant in either package must be mirrored in the other.
private var EXIT_NO_TESTS_FOUND: CInt {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied verbatim from Swift Testing's PR.

@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan grynspan enabled auto-merge (squash) July 15, 2024 19:46
@grynspan grynspan merged commit 81fdf8b into main Jul 15, 2024
5 checks passed
@grynspan grynspan deleted the jgrynspan/detect-swift-testing-EXIT_NO_TESTS_FOUND branch July 15, 2024 20:19
grynspan added a commit that referenced this pull request Jul 16, 2024
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.
grynspan added a commit that referenced this pull request Jul 18, 2024
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.
grynspan added a commit that referenced this pull request Jul 19, 2024
…Swift Testing enabled by default.) (#7794)

**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

---------

Co-authored-by: Pavel Yaskevich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug swift test Changes impacting `swift test` tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants