Skip to content

Introduce issue handling trait (as SPI) #1080

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 2 commits into from
Apr 25, 2025

Conversation

stmontgomery
Copy link
Contributor

This introduces a new trait type named IssueHandlingTrait as SPI. It allows observing, transforming, or filtering the issue(s) recorded during the test it's applied to. Here's a contrived example:

@Test(.transformIssues { issue in
  var issue = issue
  issue.comments.append("A comparison of two literals")
  return issue  // Or, return `nil` to suppress the issue
})
func example() {
  #expect(1 == 2)
}

Motivation:

Sometimes it can be useful to customize an issue recorded during a test. For example, you might wish to add supplemental information to it, such by adding comments. Another example of this could be adding an attachment to an issue, which was a capability mentioned as a future direction in ST-0009 Attachments.

Other times, you might wish to suppress an issue which is later determined to be irrelevant or cannot be marked as a known issue. Or, you may simply want to be notified that an issue was recorded, to react to it in some other way while still recording the issue normally.

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://140144041

Resolves rdar://140144041
@stmontgomery stmontgomery added enhancement New feature or request issue-handling Related to Issue handling within the testing library traits Issues and PRs related to the trait subsystem or built-in traits labels Apr 16, 2025
@stmontgomery stmontgomery added this to the Swift 6.x milestone Apr 16, 2025
@stmontgomery stmontgomery self-assigned this Apr 16, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

The macOS CI failure is expected to be resolved by swiftlang/swift#80830, but the release of a new main snapshot toolchain is currently blocked for unrelated reasons. Proceeding to merge.

@stmontgomery stmontgomery merged commit 6023a5f into swiftlang:main Apr 25, 2025
2 of 3 checks passed
@stmontgomery stmontgomery deleted the issue-handling-trait branch April 25, 2025 20:39
@stmontgomery stmontgomery modified the milestones: Swift 6.x, Swift 6.2 May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request issue-handling Related to Issue handling within the testing library traits Issues and PRs related to the trait subsystem or built-in traits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants