@@ -56,8 +56,9 @@ extension Event {
5656 /// The instant at which the test started.
5757 var startInstant : Test . Clock . Instant
5858
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 ] = [ : ]
6162
6263 /// The number of known issues recorded for the test.
6364 var knownIssueCount = 0
@@ -114,27 +115,36 @@ extension Event.HumanReadableOutputRecorder {
114115 /// - graph: The graph to walk while counting issues.
115116 ///
116117 /// - 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 ) {
118119 guard let graph else {
119- return ( 0 , 0 , 0 , " " )
120+ return ( 0 , 0 , 0 , 0 , " " )
120121 }
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 , += )
122124 let knownIssueCount = graph. compactMap ( \. value? . knownIssueCount) . reduce ( into: 0 , += )
123- let totalIssueCount = issueCount + knownIssueCount
125+ let totalIssueCount = errorIssueCount + warningIssueCount + knownIssueCount
124126
125127 // 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 ) :
128132 " 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 ) :
130136 " 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 ) :
132140 " with \( totalIssueCount. counting ( " issue " ) ) "
133- case ( false , false ) :
141+ case ( false , true , false ) :
142+ " with \( warningIssueCount. counting ( " warning " ) ) "
143+ case ( false , false , false ) :
134144 " "
135145 }
136146
137- return ( issueCount , knownIssueCount, totalIssueCount, description)
147+ return ( errorIssueCount , warningIssueCount , knownIssueCount, totalIssueCount, description)
138148 }
139149}
140150
@@ -267,7 +277,8 @@ extension Event.HumanReadableOutputRecorder {
267277 if issue. isKnown {
268278 testData. knownIssueCount += 1
269279 } else {
270- testData. issueCount += 1
280+ let issueCount = testData. issueCount [ issue. severity] ?? 0
281+ testData. issueCount [ issue. severity] = issueCount + 1
271282 }
272283 context. testData [ id] = testData
273284
@@ -355,15 +366,15 @@ extension Event.HumanReadableOutputRecorder {
355366 let testData = testDataGraph? . value ?? . init( startInstant: instant)
356367 let issues = _issueCounts ( in: testDataGraph)
357368 let duration = testData. startInstant. descriptionOfDuration ( to: instant)
358- return if issues. issueCount > 0 {
369+ return if issues. errorIssueCount > 0 {
359370 CollectionOfOne (
360371 Message (
361372 symbol: . fail,
362373 stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) failed after \( duration) \( issues. description) . "
363374 )
364375 ) + _formattedComments( for: test)
365376 } else {
366- [
377+ [
367378 Message (
368379 symbol: . pass( knownIssueCount: issues. knownIssueCount) ,
369380 stringValue: " \( _capitalizedTitle ( for: test) ) \( testName) passed after \( duration) \( issues. description) . "
@@ -400,13 +411,19 @@ extension Event.HumanReadableOutputRecorder {
400411 " "
401412 }
402413 let symbol : Event . Symbol
403- let known : String
414+ let subject : String
404415 if issue. isKnown {
405416 symbol = . pass( knownIssueCount: 1 )
406- known = " known "
417+ subject = " a known issue "
407418 } 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+ }
410427 }
411428
412429 var additionalMessages = [ Message] ( )
@@ -435,13 +452,13 @@ extension Event.HumanReadableOutputRecorder {
435452 let primaryMessage : Message = if parameterCount == 0 {
436453 Message (
437454 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) " ,
439456 conciseStringValue: String ( describing: issue. kind)
440457 )
441458 } else {
442459 Message (
443460 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) " ,
445462 conciseStringValue: String ( describing: issue. kind)
446463 )
447464 }
@@ -498,7 +515,7 @@ extension Event.HumanReadableOutputRecorder {
498515 let runStartInstant = context. runStartInstant ?? instant
499516 let duration = runStartInstant. descriptionOfDuration ( to: instant)
500517
501- return if issues. issueCount > 0 {
518+ return if issues. errorIssueCount > 0 {
502519 [
503520 Message (
504521 symbol: . fail,
0 commit comments