diff --git a/Sources/Testing/ABI/EntryPoints/EntryPoint.swift b/Sources/Testing/ABI/EntryPoints/EntryPoint.swift index 725ef91ff..73052b503 100644 --- a/Sources/Testing/ABI/EntryPoints/EntryPoint.swift +++ b/Sources/Testing/ABI/EntryPoints/EntryPoint.swift @@ -51,14 +51,14 @@ func entryPoint(passing args: __CommandLineArguments_v0?, eventHandler: Event.Ha #if !SWT_NO_FILE_IO // Configure the event recorder to write events to stderr. - var options = Event.ConsoleOutputRecorder.Options() - options = .for(.stderr) - let eventRecorder = Event.ConsoleOutputRecorder(options: options) { string in - try? FileHandle.stderr.write(string) - } - configuration.eventHandler = { [oldEventHandler = configuration.eventHandler] event, context in - eventRecorder.record(event, in: context) - oldEventHandler(event, context) + if configuration.verbosity > .min { + let eventRecorder = Event.ConsoleOutputRecorder(options: .for(.stderr)) { string in + try? FileHandle.stderr.write(string) + } + configuration.eventHandler = { [oldEventHandler = configuration.eventHandler] event, context in + eventRecorder.record(event, in: context) + oldEventHandler(event, context) + } } #endif diff --git a/Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift b/Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift index 3bb334742..0d93f70bc 100644 --- a/Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift +++ b/Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift @@ -79,7 +79,7 @@ extension ABIv0.Record { eventHandler(testJSON) } } else { - let messages = humanReadableOutputRecorder.record(event, in: context) + let messages = humanReadableOutputRecorder.record(event, in: context, verbosity: 0) if let eventRecord = Self(encoding: event, in: context, messages: messages) { try? JSON.withEncoding(of: eventRecord, eventHandler) } diff --git a/Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift b/Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift index 833913cde..ad4b79b8e 100644 --- a/Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift +++ b/Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift @@ -202,11 +202,27 @@ extension Event.HumanReadableOutputRecorder { /// - Parameters: /// - event: The event to record. /// - eventContext: The context associated with the event. + /// - verbosity: How verbose output should be. When the value of this + /// argument is greater than `0`, additional output is provided. When the + /// value of this argument is less than `0`, some output is suppressed. + /// If the value of this argument is `nil`, the value set for the current + /// configuration is used instead. The exact effects of this argument are + /// implementation-defined and subject to change. /// /// - Returns: An array of zero or more messages that can be displayed to the /// user. - @discardableResult public func record(_ event: borrowing Event, in eventContext: borrowing Event.Context) -> [Message] { - let verbosity = eventContext.configuration?.verbosity ?? 0 + @discardableResult public func record( + _ event: borrowing Event, + in eventContext: borrowing Event.Context, + verbosity: Int? = nil + ) -> [Message] { + let verbosity: Int = if let verbosity { + verbosity + } else if let verbosity = eventContext.configuration?.verbosity { + verbosity + } else { + 0 + } let test = eventContext.test let testName = if let test { if let displayName = test.displayName { @@ -501,12 +517,3 @@ extension Event.HumanReadableOutputRecorder { // MARK: - Codable extension Event.HumanReadableOutputRecorder.Message: Codable {} - -// MARK: - Deprecated - -extension Event.HumanReadableOutputRecorder { - @available(*, deprecated, message: "Use record(_:in:) instead. Verbosity is now controlled by eventContext.configuration.verbosity.") - @discardableResult public func record(_ event: borrowing Event, in eventContext: borrowing Event.Context, verbosity: Int) -> [Message] { - record(event, in: eventContext) - } -}