Skip to content

Conversation

@stmontgomery
Copy link
Contributor

This fixes a build error which can arise if the @Test(arguments:) attribute applied to a parameterized test function includes trailing trivia such as a //-style line comment on the end of the line. For example:

@Test(
  arguments: [...] // some comment
)
func example(...) { ... }

This regressed with my changes in #366 which began surrounding the argument expressions in a closure expression, in order to facilitate lazy evaluation. The fix ensures that the wrapped expression is trimmed, in addition to the outer closure (which was, and still is, trimmed).

Motivation:

Comments in this position may not be used often, but can be useful to provide context about the role or meaning of a particular collection of arguments passed to a parameterized test. So we'd like to continue supporting this.

Modifications:

  • Trim trivia from the argument expression included in the @Test macro expansion code.
  • Add test reproducing and validating this scenario.

Result:

Parameterized test functions with trailing line comments on the arguments: line now produce valid macro expansion code and build successfully.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

Resolves rdar://128609944

@stmontgomery stmontgomery added the bug 🪲 Something isn't working label May 30, 2024
@stmontgomery stmontgomery self-assigned this May 30, 2024
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test Linux

@stmontgomery
Copy link
Contributor Author

Windows CI failure is known and tracked elsewhere, merging…

@stmontgomery stmontgomery merged commit 41cd5d6 into swiftlang:main Jun 1, 2024
@stmontgomery stmontgomery deleted the strip-arguments-trivia branch June 1, 2024 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants