-
Notifications
You must be signed in to change notification settings - Fork 108
Introduce a severity level for issues, and a 'warning' severity #931
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
Changes from all commits
ff6cf12
e81ce3d
8415b90
11dec4b
6715362
7cdfeb2
ca838a3
04f115f
a51b385
fba703f
cefc62d
f224697
e9c84c3
50a6143
b8f81cf
b74187c
02996d7
ce1f4b8
5b5bfca
c7ff8a2
51c5327
39f8ac6
a101445
d7c8bdc
b64d7a3
8902a96
1e6e866
95d83ff
c23a4d6
9fa497e
57f2221
4811f39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ private import _TestingInternals | |
/// writes events to the standard error stream in addition to passing them | ||
/// to this function. | ||
/// | ||
/// - Returns: An exit code representing the result of running tests. | ||
/// | ||
/// External callers cannot call this function directly. The can use | ||
/// ``ABIv0/entryPoint-swift.type.property`` to get a reference to an ABI-stable | ||
/// version of this function. | ||
|
@@ -40,7 +42,7 @@ func entryPoint(passing args: __CommandLineArguments_v0?, eventHandler: Event.Ha | |
|
||
// Set up the event handler. | ||
configuration.eventHandler = { [oldEventHandler = configuration.eventHandler] event, context in | ||
if case let .issueRecorded(issue) = event.kind, !issue.isKnown { | ||
if case let .issueRecorded(issue) = event.kind, !issue.isKnown, issue.severity >= .error { | ||
exitCode.withLock { exitCode in | ||
exitCode = EXIT_FAILURE | ||
} | ||
|
@@ -270,6 +272,13 @@ public struct __CommandLineArguments_v0: Sendable { | |
/// The value(s) of the `--skip` argument. | ||
public var skip: [String]? | ||
|
||
/// Whether or not to include tests with the `.hidden` trait when constructing | ||
/// a test filter based on these arguments. | ||
/// | ||
/// This property is intended for use in testing the testing library itself. | ||
/// It is not parsed as a command-line argument. | ||
var includeHiddenTests: Bool? | ||
|
||
/// The value of the `--repetitions` argument. | ||
public var repetitions: Int? | ||
|
||
|
@@ -278,6 +287,13 @@ public struct __CommandLineArguments_v0: Sendable { | |
|
||
/// The value of the `--experimental-attachments-path` argument. | ||
public var experimentalAttachmentsPath: String? | ||
|
||
/// Whether or not the experimental warning issue severity feature should be | ||
/// enabled. | ||
/// | ||
/// This property is intended for use in testing the testing library itself. | ||
/// It is not parsed as a command-line argument. | ||
var isWarningIssueRecordedEventEnabled: Bool? | ||
stmontgomery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
extension __CommandLineArguments_v0: Codable { | ||
|
@@ -517,6 +533,9 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr | |
filters.append(try testFilter(forRegularExpressions: args.skip, label: "--skip", membership: .excluding)) | ||
|
||
configuration.testFilter = filters.reduce(.unfiltered) { $0.combining(with: $1) } | ||
if args.includeHiddenTests == true { | ||
configuration.testFilter.includeHiddenTests = true | ||
} | ||
|
||
// Set up the iteration policy for the test run. | ||
var repetitionPolicy: Configuration.RepetitionPolicy = .once | ||
|
@@ -547,6 +566,22 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr | |
configuration.exitTestHandler = ExitTest.handlerForEntryPoint() | ||
#endif | ||
|
||
// Warning issues (experimental). | ||
if args.isWarningIssueRecordedEventEnabled == true { | ||
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = true | ||
} else { | ||
switch args.eventStreamVersion { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now, until we've proposed the change list for ABIv1, I think we should just leave this switch out. It'll be easy to add back in v1 (actually, there's a whole different way we can do it that may be more scalable, I'll discuss with you in DMs.) I say this because somebody passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See also my comment here: https://github.com/swiftlang/swift-testing/pull/931/files#r1944900283 I realize I'm being confusing, sorry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replied there, and in the mean time we need this so the tests can opt-in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't the tests passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of right now, it's dead code since the default value is always |
||
case .some(...0): | ||
// If the event stream version was explicitly specified to a value < 1, | ||
// disable the warning issue event to maintain legacy behavior. | ||
configuration.eventHandlingOptions.isWarningIssueRecordedEventEnabled = false | ||
default: | ||
// Otherwise the requested event stream version is ≥ 1, so don't change | ||
// the warning issue event setting. | ||
break | ||
} | ||
} | ||
|
||
return configuration | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.