Skip to content

Conversation

stmontgomery
Copy link
Contributor

This updates Event.JUnitXMLRecorder to ignore Issue instances whose severity is less than .error (such as .warning).

Motivation:

The concept of issue severity was recently added in #931 (but was reverted and re-landed in #952), and that did not adjust the JUnit XML recorder logic. The JUnit XML schema we currently attempt to adhere to does not appear to have a way to represent non-fatal issues, so I think it would be best for now to ignore these issues.

Modifications:

  • Implement the fix and a validating unit test.
  • (Drive-by) Fix a nearby test I noticed wasn't actually working as intended and wasn't properly validating the fix it was intended to.

Checklist:

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

@stmontgomery stmontgomery added bug 🪲 Something isn't working swiftpm-integration 📦 Swift Package Manager integration tools integration 🛠️ Integration of swift-testing into tools/IDEs issue-handling Related to Issue handling within the testing library labels Feb 28, 2025
@stmontgomery stmontgomery added this to the Swift 6.x milestone Feb 28, 2025
@stmontgomery stmontgomery self-assigned this Feb 28, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

let context = Event.Context(test: nil, testCase: nil, configuration: nil)

let recorder = Event.JUnitXMLRecorder { string in
if string.contains("<testsuite") {
#expect(string.contains(#"failures=1"#))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a drive-by fix to the pre-existing test above the new one I added below: This one wasn't actually working, since no .runEnded event was recorded, so this callback wasn't happening. Once I fixed that I noticed a secondary issue, which is that the "failures=1" string was missing double quotes around the number 1.

@stmontgomery stmontgomery merged commit 69a1e26 into swiftlang:main Feb 28, 2025
3 checks passed
@stmontgomery stmontgomery deleted the junitxml-warnings branch February 28, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working issue-handling Related to Issue handling within the testing library swiftpm-integration 📦 Swift Package Manager integration tools integration 🛠️ Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants