Skip to content

Commit 16c6864

Browse files
authored
Merge pull request #2945 from stmontgomery/ST-0013-formatting
Improve formatting of ST-0013 and update status
2 parents 08deb52 + eac7827 commit 16c6864

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

proposals/testing/0013-issue-severity-warning.md

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
- Proposal: [ST-0013](0013-issue-severity-warning.md)
44
- Authors: [Suzy Ratcliff](https://github.com/suzannaratcliff)
55
- Review Manager: [Maarten Engels](https://github.com/maartene)
6-
- Status: **Accepted**
7-
- Implementation: [swiftlang/swift-testing#1075](https://github.com/swiftlang/swift-testing/pull/1075)
8-
- Review: ([pitch](https://forums.swift.org/t/pitch-test-issue-warnings/79285)) ([review](https://forums.swift.org/t/st-0013-test-issue-warnings/80991)) ([accepted](https://forums.swift.org/t/accepted-st-0013-test-issue-severity/81385))
6+
- Status: **Implemented (Swift 6.3)**
7+
- Implementation: [swiftlang/swift-testing#1075](https://github.com/swiftlang/swift-testing/pull/1075),
8+
[swiftlang/swift-testing#1247](https://github.com/swiftlang/swift-testing/pull/1247)
9+
- Review: ([pitch](https://forums.swift.org/t/pitch-test-issue-warnings/79285)) ([review](https://forums.swift.org/t/st-0013-test-issue-warnings/80991)) ([acceptance](https://forums.swift.org/t/accepted-st-0013-test-issue-severity/81385))
910

1011
## Introduction
1112

@@ -48,6 +49,7 @@ The `Severity` enum:
4849
```swift
4950
extension Issue {
5051
// ...
52+
5153
public enum Severity: Codable, Comparable, CustomStringConvertible, Sendable {
5254
/// The severity level for an issue which should be noted but is not
5355
/// necessarily an error.
@@ -62,7 +64,6 @@ extension Issue {
6264
/// marked as a failure.
6365
case error
6466
}
65-
// ...
6667
}
6768
```
6869

@@ -77,6 +78,9 @@ Issue.record("My comment", severity: .warning)
7778
Here is the `Issue.record` method definition with severity as a parameter.
7879

7980
```swift
81+
extension Issue {
82+
// ...
83+
8084
/// Record an issue when a running test and an issue occurs.
8185
///
8286
/// - Parameters:
@@ -95,8 +99,7 @@ Here is the `Issue.record` method definition with severity as a parameter.
9599
severity: Severity = .error,
96100
sourceLocation: SourceLocation = #_sourceLocation
97101
) -> Self
98-
99-
// ...
102+
}
100103
```
101104

102105
### Issue Type Enhancements
@@ -106,13 +109,11 @@ The Issue type is enhanced with two new properties to better handle and report i
106109
- `severity`: This property allows access to the specific severity level of an issue, enabling more precise handling of test results.
107110

108111
```swift
109-
// ...
110-
111112
extension Issue {
113+
// ...
112114

113-
/// The severity of the issue.
114-
public var severity: Severity { get set }
115-
115+
/// The severity of the issue.
116+
public var severity: Severity { get set }
116117
}
117118

118119
```
@@ -140,31 +141,32 @@ extension Issue {
140141
Example usage of `severity` and `isFailure`:
141142

142143
```swift
143-
// ...
144144
withKnownIssue {
145145
// ...
146146
} matching: { issue in
147-
return issue.isFailure || issue.severity > .warning
147+
issue.isFailure || issue.severity > .warning
148148
}
149149
```
150150

151151
For more details on `Issue`, refer to the [Issue Documentation](https://developer.apple.com/documentation/testing/issue).
152152

153153
This revision aims to clarify the functionality and usage of the `Severity` enum and `Issue` properties while maintaining consistency with the existing Swift API standards.
154154

155-
### Integration with supporting tools
155+
## Integration with supporting tools
156+
157+
### Event stream
156158

157159
Issue severity will be in the event stream output when a `issueRecorded` event occurs. This will be a breaking change because some tools may assume that all `issueRecorded` events are failing. Due to this we will be bumping the event stream version and v1 will maintain it's behavior and not output any events for non failing issues. We will also be adding `isFailure` to the issue so that clients will know if the issue should be treated as a failure. `isFailure` is a computed property.
158160

159161
The JSON event stream ABI will be amended correspondingly:
160162

161-
```
162-
<issue> ::= {
163-
"isKnown": <bool>, ; is this a known issue or not?
164-
+ "severity": <string>, ; the severity of the issue
165-
+ "isFailure": <bool>, ; if the issue is a failing issue
166-
["sourceLocation": <source-location>,] ; where the issue occurred, if known
167-
}
163+
```diff
164+
<issue> ::= {
165+
"isKnown": <bool>, ; is this a known issue or not?
166+
+ "severity": <string>, ; the severity of the issue
167+
+ "isFailure": <bool>, ; if the issue is a failing issue
168+
["sourceLocation": <source-location>,] ; where the issue occurred, if known
169+
}
168170
```
169171

170172
Example of an `issueRecorded` event in the json output:
@@ -175,29 +177,21 @@ Example of an `issueRecorded` event in the json output:
175177

176178
### Console output
177179

178-
When there is an issue recorded with severity warning the output looks like this:
180+
When there is an issue recorded with severity warning, such as using the following code:
179181

180182
```swift
181-
Issue.record("My comment", severity: .warning)
182-
```
183-
184-
```
185-
􀟈 Test "All elements of two ranges are equal" started.
186-
􀄣 Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
187-
􀄵 My comment
188-
􁁛 Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
183+
Issue.record("My comment", severity: .warning)
189184
```
190185

191-
### Trying this out
192-
193-
To use severity today, checkout the branch here: https://github.com/swiftlang/swift-testing/pull/1189
186+
the console output will look like the following:
194187

195188
```
196-
.package(url: "https://github.com/suzannaratcliff/swift-testing.git", branch: "suzannaratcliff:suzannaratcliff/enable-severity"),
189+
◇ Test "All elements of two ranges are equal" started.
190+
� Test "All elements of two ranges are equal" recorded a warning at ZipTests.swift:32:17: Issue recorded
191+
↳ My comment
192+
✔ Test "All elements of two ranges are equal" passed after 0.001 seconds with 1 warning.
197193
```
198194

199-
For more details on how to checkout a branch for a package refer to this: https://developer.apple.com/documentation/packagedescription/package/dependency/package(url:branch:)
200-
201195
## Alternatives considered
202196

203197
- Separate Issue Creation and Recording: We considered providing a mechanism to create issues independently before recording them, rather than passing the issue details directly to the `record` method. This approach was ultimately set aside in favor of simplicity and directness in usage.

0 commit comments

Comments
 (0)