@@ -56,8 +56,9 @@ extension Event {
56
56
/// The instant at which the test started.
57
57
var startInstant : Test . Clock . Instant
58
58
59
- /// The number of issues recorded for the test.
60
- var issueCount = 0
59
+ /// The number of issues recorded for the test, grouped by their
60
+ /// level of severity.
61
+ var issueCount : [ Issue . Severity : Int ] = [ : ]
61
62
62
63
/// The number of known issues recorded for the test.
63
64
var knownIssueCount = 0
@@ -114,27 +115,36 @@ extension Event.HumanReadableOutputRecorder {
114
115
/// - graph: The graph to walk while counting issues.
115
116
///
116
117
/// - Returns: A tuple containing the number of issues recorded in `graph`.
117
- private func _issueCounts( in graph: Graph < String , Event . HumanReadableOutputRecorder . _Context . TestData ? > ? ) -> ( issueCount : Int , knownIssueCount: Int , totalIssueCount: Int , description: String ) {
118
+ private func _issueCounts( in graph: Graph < String , Event . HumanReadableOutputRecorder . _Context . TestData ? > ? ) -> ( errorIssueCount : Int , warningIssueCount : Int , knownIssueCount: Int , totalIssueCount: Int , description: String ) {
118
119
guard let graph else {
119
- return ( 0 , 0 , 0 , " " )
120
+ return ( 0 , 0 , 0 , 0 , " " )
120
121
}
121
- let issueCount = graph. compactMap ( \. value? . issueCount) . reduce ( into: 0 , += )
122
+ let errorIssueCount = graph. compactMap ( \. value? . issueCount [ . error] ) . reduce ( into: 0 , += )
123
+ let warningIssueCount = graph. compactMap ( \. value? . issueCount [ . warning] ) . reduce ( into: 0 , += )
122
124
let knownIssueCount = graph. compactMap ( \. value? . knownIssueCount) . reduce ( into: 0 , += )
123
- let totalIssueCount = issueCount + knownIssueCount
125
+ let totalIssueCount = errorIssueCount + warningIssueCount + knownIssueCount
124
126
125
127
// Construct a string describing the issue counts.
126
- let description = switch ( issueCount > 0 , knownIssueCount > 0 ) {
127
- case ( true , true ) :
128
+ let description = switch ( errorIssueCount > 0 , warningIssueCount > 0 , knownIssueCount > 0 ) {
129
+ case ( true , true , true ) :
130
+ " with \( totalIssueCount. counting ( " issue " ) ) (including \( warningIssueCount. counting ( " warning " ) ) and \( knownIssueCount. counting ( " known issue " ) ) ) "
131
+ case ( true , false , true ) :
128
132
" with \( totalIssueCount. counting ( " issue " ) ) (including \( knownIssueCount. counting ( " known issue " ) ) ) "
129
- case ( false , true ) :
133
+ case ( false , true , true ) :
134
+ " with \( warningIssueCount. counting ( " warning " ) ) and \( knownIssueCount. counting ( " known issue " ) ) "
135
+ case ( false , false , true ) :
130
136
" with \( knownIssueCount. counting ( " known issue " ) ) "
131
- case ( true , false ) :
137
+ case ( true , true , false ) :
138
+ " with \( totalIssueCount. counting ( " issue " ) ) (including \( warningIssueCount. counting ( " warning " ) ) ) "
139
+ case ( true , false , false ) :
132
140
" with \( totalIssueCount. counting ( " issue " ) ) "
133
- case ( false , false ) :
141
+ case ( false , true , false ) :
142
+ " with \( warningIssueCount. counting ( " warning " ) ) "
143
+ case ( false , false , false ) :
134
144
" "
135
145
}
136
146
137
- return ( issueCount , knownIssueCount, totalIssueCount, description)
147
+ return ( errorIssueCount , warningIssueCount , knownIssueCount, totalIssueCount, description)
138
148
}
139
149
}
140
150
@@ -267,7 +277,8 @@ extension Event.HumanReadableOutputRecorder {
267
277
if issue. isKnown {
268
278
testData. knownIssueCount += 1
269
279
} else {
270
- testData. issueCount += 1
280
+ let issueCount = testData. issueCount [ issue. severity] ?? 0
281
+ testData. issueCount [ issue. severity] = issueCount + 1
271
282
}
272
283
context. testData [ id] = testData
273
284
@@ -355,15 +366,15 @@ extension Event.HumanReadableOutputRecorder {
355
366
let testData = testDataGraph? . value ?? . init( startInstant: instant)
356
367
let issues = _issueCounts ( in: testDataGraph)
357
368
let duration = testData. startInstant. descriptionOfDuration ( to: instant)
358
- return if issues. issueCount > 0 {
369
+ return if issues. errorIssueCount > 0 {
359
370
CollectionOfOne (
360
371
Message (
361
372
symbol: . fail,
362
373
stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) failed after \( duration) \( issues. description) . "
363
374
)
364
375
) + _formattedComments( for: test)
365
376
} else {
366
- [
377
+ [
367
378
Message (
368
379
symbol: . pass( knownIssueCount: issues. knownIssueCount) ,
369
380
stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) passed after \( duration) \( issues. description) . "
@@ -400,13 +411,19 @@ extension Event.HumanReadableOutputRecorder {
400
411
" "
401
412
}
402
413
let symbol : Event . Symbol
403
- let known : String
414
+ let subject : String
404
415
if issue. isKnown {
405
416
symbol = . pass( knownIssueCount: 1 )
406
- known = " known "
417
+ subject = " a known issue "
407
418
} else {
408
- symbol = . fail
409
- known = " n "
419
+ switch issue. severity {
420
+ case . warning:
421
+ symbol = . passWithWarnings
422
+ subject = " a warning "
423
+ case . error:
424
+ symbol = . fail
425
+ subject = " an issue "
426
+ }
410
427
}
411
428
412
429
var additionalMessages = [ Message] ( )
@@ -435,13 +452,13 @@ extension Event.HumanReadableOutputRecorder {
435
452
let primaryMessage : Message = if parameterCount == 0 {
436
453
Message (
437
454
symbol: symbol,
438
- 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) " ,
445
462
conciseStringValue: String ( describing: issue. kind)
446
463
)
447
464
}
@@ -498,7 +515,7 @@ extension Event.HumanReadableOutputRecorder {
498
515
let runStartInstant = context. runStartInstant ?? instant
499
516
let duration = runStartInstant. descriptionOfDuration ( to: instant)
500
517
501
- return if issues. issueCount > 0 {
518
+ return if issues. errorIssueCount > 0 {
502
519
[
503
520
Message (
504
521
symbol: . fail,
0 commit comments