From 6f65917c2f1008950d303171782bbc7edd3759f9 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 21 Sep 2023 13:48:40 -0400 Subject: [PATCH] Fix miscounting the number of parameters when an issue is recorded. We're accidentally reporting the number of characters in the string representation of each argument as the number of arguments. --- Sources/Testing/Events/Event.Recorder.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Testing/Events/Event.Recorder.swift b/Sources/Testing/Events/Event.Recorder.swift index 29c87bee6..987c2f25b 100644 --- a/Sources/Testing/Events/Event.Recorder.swift +++ b/Sources/Testing/Events/Event.Recorder.swift @@ -530,6 +530,11 @@ extension Event.Recorder { context.testData.insertValue(testData, at: id) } } + let parameterCount = if let parameters = event.test?.parameters { + parameters.count + } else { + 0 + } let labeledArguments = if let testCase = event.testCase, let parameters = event.test?.parameters { testCase.labeledArguments(using: parameters) } else { @@ -557,10 +562,10 @@ extension Event.Recorder { } let atSourceLocation = issue.sourceLocation.map { " at \($0)" } ?? "" - if labeledArguments.isEmpty { + if parameterCount == 0 { return "\(symbol) Test \(testName) recorded a\(known) issue\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n" } else { - return "\(symbol) Test \(testName) recorded a\(known) issue with \(labeledArguments.count.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n" + return "\(symbol) Test \(testName) recorded a\(known) issue with \(parameterCount.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n" } case .testCaseStarted: