-
Notifications
You must be signed in to change notification settings - Fork 302
Trim parameter names in SwiftTestingScanner #1209
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
Trim parameter names in SwiftTestingScanner #1209
Conversation
Test specified with anonymous arguments would produce an id with extra whitespace, i.e: `funcWithArgument(_ x: Int)` would produce a TestItem id of `funcWithArgument(_ :)` This patch trims this extra whitespace to produce IDs that are consistent with Swift's function ids, i.e: `funcWithArgument(_:)`
@@ -292,7 +292,7 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor { | |||
} | |||
|
|||
let name = | |||
node.name.text + "(" + node.signature.parameterClause.parameters.map { "\($0.firstName):" }.joined() + ")" |
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.
So, this is still not quite correct because of optional leading/trailing backticks. See swiftlang/swift-syntax#1936.
swift-testing has logic to trim these off that you may need to adopt.
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.
Seems like the best course of action is to leverage swiftlang/swift-syntax#2576 when its ready. @ahoppen In the short term is it worth stripping the backticks in the TestItem initializer until the proper solution is merged?
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.
Long-term yes, short-term we'll need you to remove them manually I think. (Whether or not it's "worth it" is subjective, but swift-testing's own test suite checks for this sort of thing.)
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.
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's fine—let's just not forget.
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.
Created #1211 as a stopgap until swiftlang/swift-syntax#2576 is ready
@swift-ci Please test |
@swift-ci Please test Windows |
Test specified with anonymous arguments would produce an id with extra whitespace, i.e:
funcWithArgument(_ x: Int)
would produce a TestItem id offuncWithArgument(_ :)
This patch trims this extra whitespace to produce IDs that are consistent with Swift's function ids, i.e:
funcWithArgument(_:)