-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Tests: repair the Generation tests on Windows #6354
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
Mirror the `testOnLinux` for Windows with a `testOnWindows`. This allows us to skip some tests dynamically as we do on Linux.
Here's an example of your CHANGELOG entry: * Tests: repair the Generation tests on Windows.
[compnerd](https://github.com/compnerd)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
Windows isolates XCTest/Testing from the platform SDK as they are not part of the redistributable components. We adjust the flags by querying the partial path information and computing the location for the `XCTest` module for the tests. Additionally, enable the ObjC interop on the test cases to allow parsing `@objc` modifiers on declarations. This allows us to pass the GeneratedTests test suite.
|
Neat! |
SimplyDanny
left a comment
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.
Looks good to me apart from two nits.
We could probably come up with semantically equal test cases that would also work on Windows, but excluding them is also fine as we're not testing anything platform-related. So logic that works on Linux/macOS will also work on Windows anyway.
| .deletingLastPathComponent() | ||
| .deletingLastPathComponent() | ||
| .appendingPathComponent("Library") | ||
| .appendingPathComponent("XCTest-\(info.defaults.versionXCTest)") |
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 could use
| .appendingPathComponent("XCTest-\(info.defaults.versionXCTest)") | |
| .appendingPathComponent("XCTest-\(SwiftVersion.current.rawValue)") |
here which directly interacts with SourceKit to retrieve the version. Not sure whether it's safe to assume that Swift version == XCTest version, though. For the 6.2.1 toolchain, that's the case.
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 don't think that is entirely safe to assume (though it does currently hold). That is the reason for the deserialisation of the plist - it encodes the information for the SDK itself which is embedded at build time.
|
Relates to #6352. |
Co-authored-by: Danny Mösch <[email protected]>
| .appendingPathComponent("lib") | ||
| .appendingPathComponent("swift") | ||
| .appendingPathComponent("windows") | ||
| .path |
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.
Do we need to use .filepath from your other PR here as well?
This pull request adds support for testing SwiftLint rule examples on Windows, alongside existing support for Linux and macOS. The most significant changes include introducing a new
testOnWindowsproperty to theExamplemodel, updating rule example definitions to use this property, and modifying test helpers to conditionally run tests based on platform. Additionally, Windows-specific logic for test setup has been added to ensure compatibility.Platform support enhancements:
testOnWindowsproperty to theExamplestruct and updated its initializer to allow specifying whether an example should be tested on Windows. (Source/SwiftLintCore/Models/Example.swift) [1] [2]testOnWindows: falseflag where appropriate, ensuring tests are only run on supported platforms. (Source/SwiftLintBuiltInRules/Rules/Lint/UnusedImportRuleExamples.swift) [1] [2] [3]Test infrastructure improvements:
testOnWindowsproperty before running tests, analogous to the existing Linux checks. (Tests/TestHelpers/TestHelpers.swift)Tests/TestHelpers/TestHelpers.swift) [1] [2]