Skip to content
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

Test: Add platform helpers #8099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bkhouri
Copy link
Contributor

@bkhouri bkhouri commented Nov 5, 2024

Add helpers related to the current platform to assist with conditionally running test cases.

Motivation:

Some XCTests have the following implementation, or a variation thereof

#if os(macOS)
    func testLibraryEnvironmentVariable() async throws {
       //test implementation
    }
#endif

The idiomatic Swift Testing is to use the enabled/disabled traits, thus allowing the test to be compiled. As such, create some helpers function. that will allow enabling/disabling a test using these helper functions.

Modifications:

Add helper functions and add some Swift Testing tests.

Result:

Ran the equivalent of the following and ensured there were no test-related failures

for _ in $(seq 0 100);
do
    swift test --enable-swift-testing --disable-xctest
done

Blocked by #8137
Requires swiftlang/swift#78300

@bkhouri bkhouri changed the title Test: Add platform helpers [DRAFT] Test: Add platform helpers Nov 5, 2024
@bkhouri bkhouri changed the title [DRAFT] Test: Add platform helpers Test: Add platform helpers Nov 7, 2024
@bkhouri
Copy link
Contributor Author

bkhouri commented Nov 7, 2024

Ready for review, though it may be blocked as not all pipeline builds run with Swift 6.0!

@bkhouri
Copy link
Contributor Author

bkhouri commented Nov 22, 2024

This PR is blocked by #8137

@bkhouri bkhouri force-pushed the t/main/platformhelpers branch from 8b71a84 to afa76d9 Compare December 3, 2024 18:03
@bkhouri bkhouri marked this pull request as ready for review December 19, 2024 01:25
@bkhouri
Copy link
Contributor Author

bkhouri commented Dec 20, 2024

Please test with following pull request:
swiftlang/swift#78300

@swift-ci Please test

@grynspan
Copy link
Contributor

Be aware: this won't work reliably for tests where the test content is only compilable on one platform or another.

@bkhouri
Copy link
Contributor Author

bkhouri commented Dec 20, 2024

Be aware: this won't work reliably for tests where the test content is only compilable on one platform or another.

@grynspan : Could you please clarify this?

arguments: [
(name: "", expected: false),
(name: "DOES_NOT_EXIST", expected: false),
(name: "HOME", expected: true)
Copy link
Contributor Author

@bkhouri bkhouri Dec 20, 2024

Choose a reason for hiding this comment

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

thought: this test will likely need to be revisited when addressing #8121 and #8176

@bkhouri bkhouri added the test suite improvements to SwiftPM test suite label Dec 20, 2024
@bkhouri
Copy link
Contributor Author

bkhouri commented Jan 15, 2025

@swift-ci please test

Add helpers related to the current platform to assist with conditionally
running test cases.
@bkhouri bkhouri force-pushed the t/main/platformhelpers branch from afa76d9 to ba51fbf Compare January 17, 2025 06:40
@bkhouri bkhouri requested a review from plemarquand January 17, 2025 06:41
@bkhouri
Copy link
Contributor Author

bkhouri commented Jan 17, 2025

@swift-ci please test

@bkhouri
Copy link
Contributor Author

bkhouri commented Jan 17, 2025

@swift-ci please test windows

1 similar comment
@bkhouri
Copy link
Contributor Author

bkhouri commented Jan 17, 2025

@swift-ci please test windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test suite improvements to SwiftPM test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants