You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce a severity level for issues, and a 'warning' severity (#931)
This introduces the concept of severity to the `Issue` type, represented by a new enum `Issue.Severity` with two cases: `.warning` and `.error`. Error is the default severity for all issues, matching current behavior, but warning is provided as a new option which does not cause the test the issue is associated with to be marked as a failure. In this PR, these are [SPI](https://github.com/swiftlang/swift-testing/blob/main/Documentation/SPI.md) but they could be considered for promotion to public API eventually. Additional work would be needed to permit test authors to record issues with severity < `.error`, since APIs like `Issue.record()` are not being modified at this time to allow customizing the severity. ### Motivation: There are certain situations where a problem may arise during a test that doesn't necessarily affect its outcome or signal an important problem, but is worth calling attention to. A specific example use case I have in mind is to allow the testing library to record a warning issue about problems with the arguments passed to a parameterized test, such as having duplicate arguments. ### Modifications: - Introduce `Issue.Severity` as an SPI enum. - Introduce an SPI property `severity` to `Issue` with default value `.error`. - Modify entry point logic to exit with `EXIT_SUCCESS` if all issues recorded had severity < `.error`. - Modify console output formatting logic and data structures to represent warning issues sensibly. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated. - [x] Add new tests
stringValue:"\(_capitalizedTitle(for: test))\(testName) recorded a\(known) issue\(atSourceLocation): \(issue.kind)",
455
+
stringValue:"\(_capitalizedTitle(for: test))\(testName) recorded \(subject)\(atSourceLocation): \(issue.kind)",
439
456
conciseStringValue:String(describing: issue.kind)
440
457
)
441
458
}else{
442
459
Message(
443
460
symbol: symbol,
444
-
stringValue:"\(_capitalizedTitle(for: test))\(testName) recorded a\(known) issue with \(parameterCount.counting("argument"))\(labeledArguments)\(atSourceLocation): \(issue.kind)",
461
+
stringValue:"\(_capitalizedTitle(for: test))\(testName) recorded \(subject) with \(parameterCount.counting("argument"))\(labeledArguments)\(atSourceLocation): \(issue.kind)",
0 commit comments