Skip to content

[5.5] fix a bug in test discovery where tests define in extensions break the discovery #3435

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 1 commit into from
Apr 23, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Apr 23, 2021

bring #3433 to 5.5

…e discovery (swiftlang#3433)

motivation: less bugs, happier users

changes: modify test discovery code to key of class name rather than blindly iterate over tetst

rdar://58435666
@tomerd
Copy link
Contributor Author

tomerd commented Apr 23, 2021

@swift-ci please test

@tomerd tomerd self-assigned this Apr 23, 2021
stream <<< "import XCTest" <<< "\n"
stream <<< "@testable import " <<< module <<< "\n"

for klass in tests {
for classTests in testsByClass {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is now iterating over a dictionary instead of an array, should the keys be sorted here to avoid spurious differences in how the output file is emitted?

Copy link
Contributor Author

@tomerd tomerd Apr 23, 2021

Choose a reason for hiding this comment

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

do you mean so that the output won't cause unnecessary compiles? if so, I think this is a good idea but I would do that in a separate optimization PR on main, and let the fix through as-is in 5.5

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's what I meant — just to always have stable outputs. Agreed that it can be done separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -74,8 +78,8 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
return [\n
"""

for klass in tests {
stream <<< indent(8) <<< "testCase(\(klass.name).__allTests__\(klass.name)),\n"
for className in testsByClass.keys {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here about order.

@abertelrud abertelrud self-requested a review April 23, 2021 21:45
@tomerd tomerd merged commit 6007590 into swiftlang:release/5.5 Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants