Skip to content

Commit 9998633

Browse files
authored
Merge pull request #950 from stmontgomery/revert-issue-severity
Revert "Introduce a severity level for issues, and a 'warning' severity (#931)"
2 parents 55d0023 + afe2505 commit 9998633

18 files changed

+109
-468
lines changed

Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension ABIv0 {
4747
/// callback.
4848
public static var entryPoint: EntryPoint {
4949
return { configurationJSON, recordHandler in
50-
try await _entryPoint(
50+
try await Testing.entryPoint(
5151
configurationJSON: configurationJSON,
5252
recordHandler: recordHandler
5353
) == EXIT_SUCCESS
@@ -87,7 +87,7 @@ typealias ABIEntryPoint_v0 = @Sendable (
8787
@usableFromInline func copyABIEntryPoint_v0() -> UnsafeMutableRawPointer {
8888
let result = UnsafeMutablePointer<ABIEntryPoint_v0>.allocate(capacity: 1)
8989
result.initialize { configurationJSON, recordHandler in
90-
try await _entryPoint(
90+
try await entryPoint(
9191
configurationJSON: configurationJSON,
9292
eventStreamVersionIfNil: -1,
9393
recordHandler: recordHandler
@@ -104,7 +104,7 @@ typealias ABIEntryPoint_v0 = @Sendable (
104104
///
105105
/// This function will be removed (with its logic incorporated into
106106
/// ``ABIv0/entryPoint-swift.type.property``) in a future update.
107-
private func _entryPoint(
107+
private func entryPoint(
108108
configurationJSON: UnsafeRawBufferPointer?,
109109
eventStreamVersionIfNil: Int? = nil,
110110
recordHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

+1-36
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ private import _TestingInternals
2020
/// writes events to the standard error stream in addition to passing them
2121
/// to this function.
2222
///
23-
/// - Returns: An exit code representing the result of running tests.
24-
///
2523
/// External callers cannot call this function directly. The can use
2624
/// ``ABIv0/entryPoint-swift.type.property`` to get a reference to an ABI-stable
2725
/// version of this function.
@@ -42,7 +40,7 @@ func entryPoint(passing args: __CommandLineArguments_v0?, eventHandler: Event.Ha
4240

4341
// Set up the event handler.
4442
configuration.eventHandler = { [oldEventHandler = configuration.eventHandler] event, context in
45-
if case let .issueRecorded(issue) = event.kind, !issue.isKnown, issue.severity >= .error {
43+
if case let .issueRecorded(issue) = event.kind, !issue.isKnown {
4644
exitCode.withLock { exitCode in
4745
exitCode = EXIT_FAILURE
4846
}
@@ -272,13 +270,6 @@ public struct __CommandLineArguments_v0: Sendable {
272270
/// The value(s) of the `--skip` argument.
273271
public var skip: [String]?
274272

275-
/// Whether or not to include tests with the `.hidden` trait when constructing
276-
/// a test filter based on these arguments.
277-
///
278-
/// This property is intended for use in testing the testing library itself.
279-
/// It is not parsed as a command-line argument.
280-
var includeHiddenTests: Bool?
281-
282273
/// The value of the `--repetitions` argument.
283274
public var repetitions: Int?
284275

@@ -287,13 +278,6 @@ public struct __CommandLineArguments_v0: Sendable {
287278

288279
/// The value of the `--experimental-attachments-path` argument.
289280
public var experimentalAttachmentsPath: String?
290-
291-
/// Whether or not the experimental warning issue severity feature should be
292-
/// enabled.
293-
///
294-
/// This property is intended for use in testing the testing library itself.
295-
/// It is not parsed as a command-line argument.
296-
var isWarningIssueRecordedEventEnabled: Bool?
297281
}
298282

299283
extension __CommandLineArguments_v0: Codable {
@@ -533,9 +517,6 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
533517
filters.append(try testFilter(forRegularExpressions: args.skip, label: "--skip", membership: .excluding))
534518

535519
configuration.testFilter = filters.reduce(.unfiltered) { $0.combining(with: $1) }
536-
if args.includeHiddenTests == true {
537-
configuration.testFilter.includeHiddenTests = true
538-
}
539520

540521
// Set up the iteration policy for the test run.
541522
var repetitionPolicy: Configuration.RepetitionPolicy = .once
@@ -566,22 +547,6 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
566547
configuration.exitTestHandler = ExitTest.handlerForEntryPoint()
567548
#endif
568549

569-
// Warning issues (experimental).
570-
if args.isWarningIssueRecordedEventEnabled == true {
571-
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = true
572-
} else {
573-
switch args.eventStreamVersion {
574-
case .some(...0):
575-
// If the event stream version was explicitly specified to a value < 1,
576-
// disable the warning issue event to maintain legacy behavior.
577-
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = false
578-
default:
579-
// Otherwise the requested event stream version is ≥ 1, so don't change
580-
// the warning issue event setting.
581-
break
582-
}
583-
}
584-
585550
return configuration
586551
}
587552

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedIssue.swift

-19
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ extension ABIv0 {
1616
/// assists in converting values to JSON; clients that consume this JSON are
1717
/// expected to write their own decoders.
1818
struct EncodedIssue: Sendable {
19-
/// An enumeration representing the level of severity of a recorded issue.
20-
///
21-
/// For descriptions of individual cases, see ``Issue/Severity-swift.enum``.
22-
enum Severity: String, Sendable {
23-
case warning
24-
case error
25-
}
26-
27-
/// The severity of this issue.
28-
///
29-
/// - Warning: Severity is not yet part of the JSON schema.
30-
var _severity: Severity
31-
3219
/// Whether or not this issue is known to occur.
3320
var isKnown: Bool
3421

@@ -46,11 +33,6 @@ extension ABIv0 {
4633
var _error: EncodedError?
4734

4835
init(encoding issue: borrowing Issue, in eventContext: borrowing Event.Context) {
49-
_severity = switch issue.severity {
50-
case .warning: .warning
51-
case .error: .error
52-
}
53-
5436
isKnown = issue.isKnown
5537
sourceLocation = issue.sourceLocation
5638
if let backtrace = issue.sourceContext.backtrace {
@@ -66,4 +48,3 @@ extension ABIv0 {
6648
// MARK: - Codable
6749

6850
extension ABIv0.EncodedIssue: Codable {}
69-
extension ABIv0.EncodedIssue.Severity: Codable {}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedMessage.swift

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ extension ABIv0 {
2525
case `default`
2626
case skip
2727
case pass
28-
case passWithWarnings = "_passWithWarnings"
2928
case passWithKnownIssue
3029
case fail
3130
case difference
@@ -45,8 +44,6 @@ extension ABIv0 {
4544
} else {
4645
.pass
4746
}
48-
case .passWithWarnings:
49-
.passWithWarnings
5047
case .fail:
5148
.fail
5249
case .difference:

Sources/Testing/Events/Event.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ extension Event {
290290
if let configuration = configuration ?? Configuration.current {
291291
// The caller specified a configuration, or the current task has an
292292
// associated configuration. Post to either configuration's event handler.
293-
if configuration.eventHandlingOptions.shouldHandleEvent(self) {
293+
switch kind {
294+
case .expectationChecked where !configuration.deliverExpectationCheckedEvents:
295+
break
296+
default:
294297
configuration.handleEvent(self, in: context)
295298
}
296299
} else {

Sources/Testing/Events/Recorder/Event.ConsoleOutputRecorder.swift

-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ extension Event.Symbol {
162162
return "\(_ansiEscapeCodePrefix)90m\(symbolCharacter)\(_resetANSIEscapeCode)"
163163
}
164164
return "\(_ansiEscapeCodePrefix)92m\(symbolCharacter)\(_resetANSIEscapeCode)"
165-
case .passWithWarnings:
166-
return "\(_ansiEscapeCodePrefix)93m\(symbolCharacter)\(_resetANSIEscapeCode)"
167165
case .fail:
168166
return "\(_ansiEscapeCodePrefix)91m\(symbolCharacter)\(_resetANSIEscapeCode)"
169167
case .warning:

Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift

+22-39
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ 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, grouped by their
60-
/// level of severity.
61-
var issueCount: [Issue.Severity: Int] = [:]
59+
/// The number of issues recorded for the test.
60+
var issueCount = 0
6261

6362
/// The number of known issues recorded for the test.
6463
var knownIssueCount = 0
@@ -115,36 +114,27 @@ extension Event.HumanReadableOutputRecorder {
115114
/// - graph: The graph to walk while counting issues.
116115
///
117116
/// - Returns: A tuple containing the number of issues recorded in `graph`.
118-
private func _issueCounts(in graph: Graph<String, Event.HumanReadableOutputRecorder._Context.TestData?>?) -> (errorIssueCount: Int, warningIssueCount: Int, knownIssueCount: Int, totalIssueCount: Int, description: String) {
117+
private func _issueCounts(in graph: Graph<String, Event.HumanReadableOutputRecorder._Context.TestData?>?) -> (issueCount: Int, knownIssueCount: Int, totalIssueCount: Int, description: String) {
119118
guard let graph else {
120-
return (0, 0, 0, 0, "")
119+
return (0, 0, 0, "")
121120
}
122-
let errorIssueCount = graph.compactMap(\.value?.issueCount[.error]).reduce(into: 0, +=)
123-
let warningIssueCount = graph.compactMap(\.value?.issueCount[.warning]).reduce(into: 0, +=)
121+
let issueCount = graph.compactMap(\.value?.issueCount).reduce(into: 0, +=)
124122
let knownIssueCount = graph.compactMap(\.value?.knownIssueCount).reduce(into: 0, +=)
125-
let totalIssueCount = errorIssueCount + warningIssueCount + knownIssueCount
123+
let totalIssueCount = issueCount + knownIssueCount
126124

127125
// Construct a string describing the issue counts.
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):
126+
let description = switch (issueCount > 0, knownIssueCount > 0) {
127+
case (true, true):
132128
" with \(totalIssueCount.counting("issue")) (including \(knownIssueCount.counting("known issue")))"
133-
case (false, true, true):
134-
" with \(warningIssueCount.counting("warning")) and \(knownIssueCount.counting("known issue"))"
135-
case (false, false, true):
129+
case (false, true):
136130
" with \(knownIssueCount.counting("known issue"))"
137-
case (true, true, false):
138-
" with \(totalIssueCount.counting("issue")) (including \(warningIssueCount.counting("warning")))"
139-
case (true, false, false):
131+
case (true, false):
140132
" with \(totalIssueCount.counting("issue"))"
141-
case(false, true, false):
142-
" with \(warningIssueCount.counting("warning"))"
143-
case(false, false, false):
133+
case(false, false):
144134
""
145135
}
146136

147-
return (errorIssueCount, warningIssueCount, knownIssueCount, totalIssueCount, description)
137+
return (issueCount, knownIssueCount, totalIssueCount, description)
148138
}
149139
}
150140

@@ -277,8 +267,7 @@ extension Event.HumanReadableOutputRecorder {
277267
if issue.isKnown {
278268
testData.knownIssueCount += 1
279269
} else {
280-
let issueCount = testData.issueCount[issue.severity] ?? 0
281-
testData.issueCount[issue.severity] = issueCount + 1
270+
testData.issueCount += 1
282271
}
283272
context.testData[id] = testData
284273

@@ -366,15 +355,15 @@ extension Event.HumanReadableOutputRecorder {
366355
let testData = testDataGraph?.value ?? .init(startInstant: instant)
367356
let issues = _issueCounts(in: testDataGraph)
368357
let duration = testData.startInstant.descriptionOfDuration(to: instant)
369-
return if issues.errorIssueCount > 0 {
358+
return if issues.issueCount > 0 {
370359
CollectionOfOne(
371360
Message(
372361
symbol: .fail,
373362
stringValue: "\(_capitalizedTitle(for: test)) \(testName) failed after \(duration)\(issues.description)."
374363
)
375364
) + _formattedComments(for: test)
376365
} else {
377-
[
366+
[
378367
Message(
379368
symbol: .pass(knownIssueCount: issues.knownIssueCount),
380369
stringValue: "\(_capitalizedTitle(for: test)) \(testName) passed after \(duration)\(issues.description)."
@@ -411,19 +400,13 @@ extension Event.HumanReadableOutputRecorder {
411400
""
412401
}
413402
let symbol: Event.Symbol
414-
let subject: String
403+
let known: String
415404
if issue.isKnown {
416405
symbol = .pass(knownIssueCount: 1)
417-
subject = "a known issue"
406+
known = " known"
418407
} else {
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-
}
408+
symbol = .fail
409+
known = "n"
427410
}
428411

429412
var additionalMessages = [Message]()
@@ -452,13 +435,13 @@ extension Event.HumanReadableOutputRecorder {
452435
let primaryMessage: Message = if parameterCount == 0 {
453436
Message(
454437
symbol: symbol,
455-
stringValue: "\(_capitalizedTitle(for: test)) \(testName) recorded \(subject)\(atSourceLocation): \(issue.kind)",
438+
stringValue: "\(_capitalizedTitle(for: test)) \(testName) recorded a\(known) issue\(atSourceLocation): \(issue.kind)",
456439
conciseStringValue: String(describing: issue.kind)
457440
)
458441
} else {
459442
Message(
460443
symbol: symbol,
461-
stringValue: "\(_capitalizedTitle(for: test)) \(testName) recorded \(subject) with \(parameterCount.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)",
444+
stringValue: "\(_capitalizedTitle(for: test)) \(testName) recorded a\(known) issue with \(parameterCount.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)",
462445
conciseStringValue: String(describing: issue.kind)
463446
)
464447
}
@@ -515,7 +498,7 @@ extension Event.HumanReadableOutputRecorder {
515498
let runStartInstant = context.runStartInstant ?? instant
516499
let duration = runStartInstant.descriptionOfDuration(to: instant)
517500

518-
return if issues.errorIssueCount > 0 {
501+
return if issues.issueCount > 0 {
519502
[
520503
Message(
521504
symbol: .fail,

Sources/Testing/Events/Recorder/Event.Symbol.swift

+2-14
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ extension Event {
2222
/// The symbol to use when a test passes.
2323
///
2424
/// - Parameters:
25-
/// - knownIssueCount: The number of known issues recorded for the test.
26-
/// The default value is `0`.
25+
/// - knownIssueCount: The number of known issues encountered by the end
26+
/// of the test.
2727
case pass(knownIssueCount: Int = 0)
2828

29-
/// The symbol to use when a test passes with one or more warnings.
30-
@_spi(Experimental)
31-
case passWithWarnings
32-
3329
/// The symbol to use when a test fails.
3430
case fail
3531

@@ -66,8 +62,6 @@ extension Event.Symbol {
6662
} else {
6763
("\u{10105B}", "checkmark.diamond.fill")
6864
}
69-
case .passWithWarnings:
70-
("\u{100123}", "questionmark.diamond.fill")
7165
case .fail:
7266
("\u{100884}", "xmark.diamond.fill")
7367
case .difference:
@@ -128,9 +122,6 @@ extension Event.Symbol {
128122
// Unicode: HEAVY CHECK MARK
129123
return "\u{2714}"
130124
}
131-
case .passWithWarnings:
132-
// Unicode: QUESTION MARK
133-
return "\u{003F}"
134125
case .fail:
135126
// Unicode: HEAVY BALLOT X
136127
return "\u{2718}"
@@ -166,9 +157,6 @@ extension Event.Symbol {
166157
// Unicode: SQUARE ROOT
167158
return "\u{221A}"
168159
}
169-
case .passWithWarnings:
170-
// Unicode: QUESTION MARK
171-
return "\u{003F}"
172160
case .fail:
173161
// Unicode: MULTIPLICATION SIGN
174162
return "\u{00D7}"

0 commit comments

Comments
 (0)