Skip to content

Include total number of suites in "run ended" console message #1116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ extension Event.HumanReadableOutputRecorder {

case .runEnded:
let testCount = context.testCount
let suiteCount = context.suiteCount
let issues = _issueCounts(in: context.testData)
let runStartInstant = context.runStartInstant ?? instant
let duration = runStartInstant.descriptionOfDuration(to: instant)
Expand All @@ -550,14 +551,14 @@ extension Event.HumanReadableOutputRecorder {
[
Message(
symbol: .fail,
stringValue: "Test run with \(testCount.counting("test")) failed after \(duration)\(issues.description)."
stringValue: "Test run with \(testCount.counting("test")) in \(suiteCount.counting("suite")) failed after \(duration)\(issues.description)."
Copy link
Contributor Author

@stmontgomery stmontgomery May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose the word "in" here, although we could alternatively choose "and", as in Test run with X tests and Y suites passed…. Open to suggestions.

)
]
} else {
[
Message(
symbol: .pass(knownIssueCount: issues.knownIssueCount),
stringValue: "Test run with \(testCount.counting("test")) passed after \(duration)\(issues.description)."
stringValue: "Test run with \(testCount.counting("test")) in \(suiteCount.counting("suite")) passed after \(duration)\(issues.description)."
)
]
}
Expand Down
39 changes: 31 additions & 8 deletions Tests/TestingTests/EventRecorderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,29 @@ struct EventRecorderTests {
print(buffer, terminator: "")
}

let testCount = Reference<Int?>()
let suiteCount = Reference<Int?>()
let issueCount = Reference<Int?>()
let knownIssueCount = Reference<Int?>()

let runFailureRegex = Regex {
One(.anyGraphemeCluster)
" Test run with "
OneOrMore(.digit)
Capture(as: testCount) { OneOrMore(.digit) } transform: { Int($0) }
" test"
Optionally("s")
" in "
Capture(as: suiteCount) { OneOrMore(.digit) } transform: { Int($0) }
" suite"
Optionally("s")
" failed "
ZeroOrMore(.any)
" with "
Capture { OneOrMore(.digit) } transform: { Int($0) }
Capture(as: issueCount) { OneOrMore(.digit) } transform: { Int($0) }
" issue"
Optionally("s")
" (including "
Capture { OneOrMore(.digit) } transform: { Int($0) }
Capture(as: knownIssueCount) { OneOrMore(.digit) } transform: { Int($0) }
" known issue"
Optionally("s")
")."
Expand All @@ -346,8 +355,10 @@ struct EventRecorderTests {
.compactMap(runFailureRegex.wholeMatch(in:))
.first
)
#expect(match.output.1 == 12)
#expect(match.output.2 == 5)
#expect(match[testCount] == 9)
#expect(match[suiteCount] == 2)
#expect(match[issueCount] == 12)
#expect(match[knownIssueCount] == 5)
}

@Test("Issue counts are summed correctly on run end for a test with only warning issues")
Expand All @@ -369,16 +380,24 @@ struct EventRecorderTests {
print(buffer, terminator: "")
}

let testCount = Reference<Int?>()
let suiteCount = Reference<Int?>()
let warningCount = Reference<Int?>()

let runFailureRegex = Regex {
One(.anyGraphemeCluster)
" Test run with "
OneOrMore(.digit)
Capture(as: testCount) { OneOrMore(.digit) } transform: { Int($0) }
" test"
Optionally("s")
" in "
Capture(as: suiteCount) { OneOrMore(.digit) } transform: { Int($0) }
" suite"
Optionally("s")
" passed "
ZeroOrMore(.any)
" with "
Capture { OneOrMore(.digit) } transform: { Int($0) }
Capture(as: warningCount) { OneOrMore(.digit) } transform: { Int($0) }
" warning"
Optionally("s")
"."
Expand All @@ -390,7 +409,9 @@ struct EventRecorderTests {
.first,
"buffer: \(buffer)"
)
#expect(match.output.1 == 1)
#expect(match[testCount] == 1)
#expect(match[suiteCount] == 1)
#expect(match[warningCount] == 1)
}
#endif

Expand Down Expand Up @@ -691,6 +712,8 @@ struct EventRecorderTests {
func n(_ arg: Int) {
#expect(arg > 0)
}

@Suite struct PredictableSubsuite {}
}

@Suite(.hidden) struct PredictablyFailingKnownIssueTests {
Expand Down