@@ -56,8 +56,11 @@ 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 with error severity recorded for the test.
60
+ var errorIssueCount = 0
61
+
62
+ /// The number of issues with warning severity recorded for the test.
63
+ var warningIssueCount = 0
61
64
62
65
/// The number of known issues recorded for the test.
63
66
var knownIssueCount = 0
@@ -114,27 +117,36 @@ extension Event.HumanReadableOutputRecorder {
114
117
/// - graph: The graph to walk while counting issues.
115
118
///
116
119
/// - 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 ) {
120
+ private func _issueCounts( in graph: Graph < String , Event . HumanReadableOutputRecorder . _Context . TestData ? > ? ) -> ( errorIssueCount : Int , warningIssueCount : Int , knownIssueCount: Int , totalIssueCount: Int , description: String ) {
118
121
guard let graph else {
119
- return ( 0 , 0 , 0 , " " )
122
+ return ( 0 , 0 , 0 , 0 , " " )
120
123
}
121
- let issueCount = graph. compactMap ( \. value? . issueCount) . reduce ( into: 0 , += )
124
+ let errorIssueCount = graph. compactMap ( \. value? . errorIssueCount) . reduce ( into: 0 , += )
125
+ let warningIssueCount = graph. compactMap ( \. value? . warningIssueCount) . reduce ( into: 0 , += )
122
126
let knownIssueCount = graph. compactMap ( \. value? . knownIssueCount) . reduce ( into: 0 , += )
123
- let totalIssueCount = issueCount + knownIssueCount
127
+ let totalIssueCount = errorIssueCount + warningIssueCount + knownIssueCount
124
128
125
129
// Construct a string describing the issue counts.
126
- let description = switch ( issueCount > 0 , knownIssueCount > 0 ) {
127
- case ( true , true ) :
130
+ let description = switch ( errorIssueCount > 0 , warningIssueCount > 0 , knownIssueCount > 0 ) {
131
+ case ( true , true , true ) :
132
+ " with \( totalIssueCount. counting ( " issue " ) ) (including \( warningIssueCount. counting ( " warning " ) ) and \( knownIssueCount. counting ( " known issue " ) ) ) "
133
+ case ( true , false , true ) :
128
134
" with \( totalIssueCount. counting ( " issue " ) ) (including \( knownIssueCount. counting ( " known issue " ) ) ) "
129
- case ( false , true ) :
135
+ case ( false , true , true ) :
136
+ " with \( warningIssueCount. counting ( " warning " ) ) and \( knownIssueCount. counting ( " known issue " ) ) "
137
+ case ( false , false , true ) :
130
138
" with \( knownIssueCount. counting ( " known issue " ) ) "
131
- case ( true , false ) :
139
+ case ( true , true , false ) :
140
+ " with \( totalIssueCount. counting ( " issue " ) ) (including \( warningIssueCount. counting ( " warning " ) ) ) "
141
+ case ( true , false , false ) :
132
142
" with \( totalIssueCount. counting ( " issue " ) ) "
133
- case ( false , false ) :
143
+ case ( false , true , false ) :
144
+ " with \( warningIssueCount. counting ( " warning " ) ) "
145
+ case ( false , false , false ) :
134
146
" "
135
147
}
136
148
137
- return ( issueCount , knownIssueCount, totalIssueCount, description)
149
+ return ( errorIssueCount , warningIssueCount , knownIssueCount, totalIssueCount, description)
138
150
}
139
151
}
140
152
@@ -267,7 +279,12 @@ extension Event.HumanReadableOutputRecorder {
267
279
if issue. isKnown {
268
280
testData. knownIssueCount += 1
269
281
} else {
270
- testData. issueCount += 1
282
+ switch issue. severity {
283
+ case . warning:
284
+ testData. warningIssueCount += 1
285
+ case . error:
286
+ testData. errorIssueCount += 1
287
+ }
271
288
}
272
289
context. testData [ id] = testData
273
290
@@ -355,15 +372,22 @@ extension Event.HumanReadableOutputRecorder {
355
372
let testData = testDataGraph? . value ?? . init( startInstant: instant)
356
373
let issues = _issueCounts ( in: testDataGraph)
357
374
let duration = testData. startInstant. descriptionOfDuration ( to: instant)
358
- return if issues. issueCount > 0 {
375
+ return if issues. errorIssueCount > 0 {
359
376
CollectionOfOne (
360
377
Message (
361
378
symbol: . fail,
362
379
stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) failed after \( duration) \( issues. description) . "
363
380
)
364
381
) + _formattedComments( for: test)
382
+ } else if issues. warningIssueCount > 0 {
383
+ [
384
+ Message (
385
+ symbol: . warning( warningIssueCount: issues. warningIssueCount) ,
386
+ stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) passed after \( duration) \( issues. description) . "
387
+ )
388
+ ]
365
389
} else {
366
- [
390
+ [
367
391
Message (
368
392
symbol: . pass( knownIssueCount: issues. knownIssueCount) ,
369
393
stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) passed after \( duration) \( issues. description) . "
@@ -400,13 +424,19 @@ extension Event.HumanReadableOutputRecorder {
400
424
" "
401
425
}
402
426
let symbol : Event . Symbol
403
- let known : String
427
+ let introducer : String
404
428
if issue. isKnown {
405
429
symbol = . pass( knownIssueCount: 1 )
406
- known = " known "
430
+ introducer = " a known"
407
431
} else {
408
- symbol = . fail
409
- known = " n "
432
+ switch issue. severity {
433
+ case . warning:
434
+ symbol = . warning( warningIssueCount: 1 )
435
+ introducer = " a warning "
436
+ case . error:
437
+ symbol = . fail
438
+ introducer = " an "
439
+ }
410
440
}
411
441
412
442
var additionalMessages = [ Message] ( )
@@ -435,13 +465,13 @@ extension Event.HumanReadableOutputRecorder {
435
465
let primaryMessage : Message = if parameterCount == 0 {
436
466
Message (
437
467
symbol: symbol,
438
- stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) recorded a \( known ) issue \( atSourceLocation) : \( issue. kind) " ,
468
+ stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) recorded \( introducer ) issue \( atSourceLocation) : \( issue. kind) " ,
439
469
conciseStringValue: String ( describing: issue. kind)
440
470
)
441
471
} else {
442
472
Message (
443
473
symbol: symbol,
444
- stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) recorded a \( known ) issue with \( parameterCount. counting ( " argument " ) ) \( labeledArguments) \( atSourceLocation) : \( issue. kind) " ,
474
+ stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) recorded \( introducer ) issue with \( parameterCount. counting ( " argument " ) ) \( labeledArguments) \( atSourceLocation) : \( issue. kind) " ,
445
475
conciseStringValue: String ( describing: issue. kind)
446
476
)
447
477
}
@@ -498,13 +528,20 @@ extension Event.HumanReadableOutputRecorder {
498
528
let runStartInstant = context. runStartInstant ?? instant
499
529
let duration = runStartInstant. descriptionOfDuration ( to: instant)
500
530
501
- return if issues. issueCount > 0 {
531
+ return if issues. errorIssueCount > 0 {
502
532
[
503
533
Message (
504
534
symbol: . fail,
505
535
stringValue: " Test run with \( testCount. counting ( " test " ) ) failed after \( duration) \( issues. description) . "
506
536
)
507
537
]
538
+ } else if issues. warningIssueCount > 0 {
539
+ [
540
+ Message (
541
+ symbol: . warning( warningIssueCount: issues. warningIssueCount) ,
542
+ stringValue: " Test run with \( testCount. counting ( " test " ) ) passed after \( duration) \( issues. description) . "
543
+ )
544
+ ]
508
545
} else {
509
546
[
510
547
Message (
0 commit comments