Skip to content

Commit 392e42c

Browse files
committed
Change argument name and clarify what happens if you don't specify an event stream version
1 parent 406e98d commit 392e42c

File tree

5 files changed

+32
-27
lines changed

5 files changed

+32
-27
lines changed

Documentation/ABI/JSON.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

1313
This document outlines the JSON schemas used by the testing library for its ABI
14-
entry point and for the `--event-stream-output` command-line argument. For more
15-
information about the ABI entry point, see the documentation for
14+
entry point and for the `--event-stream-output-path` command-line argument. For
15+
more information about the ABI entry point, see the documentation for
1616
[ABIv0.EntryPoint](https://github.com/search?q=repo%3Aapple%2Fswift-testing%EntryPoint&type=code).
1717

1818
## Modified Backus-Naur form
@@ -99,8 +99,8 @@ encoded as a single [JSON Lines](https://jsonlines.org) value.
9999

100100
A stream consists of a sequence of values encoded as [JSON Lines](https://jsonlines.org).
101101
A single instance of `<output-stream>` is defined per test process and can be
102-
accessed by passing `--event-stream-output` to the test executable created by
103-
`swift build --build-tests`.
102+
accessed by passing `--event-stream-output-path` to the test executable created
103+
by `swift build --build-tests`.
104104

105105
```
106106
<output-stream> ::= <output-record>\n | <output-record>\n <output-stream>

Documentation/Proposals/NNNN-json-abi.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Package Manager:
201201
| Argument | Value Type | Description |
202202
|---|:-:|---|
203203
| `--configuration-path` | File system path | Specifies a path to a file, named pipe, etc. containing test configuration/options. |
204-
| `--event-stream-output` | File system path | Specifies a path to a file, named pipe, etc. to which output should be written. |
204+
| `--event-stream-output-path` | File system path | Specifies a path to a file, named pipe, etc. to which output should be written. |
205205
| `--event-stream-version` | Integer | Specifies the version of the stable JSON schema to use for output. |
206206

207207
The process for adding arguments to Swift Package Manager is separate from the
@@ -210,24 +210,29 @@ speculative and are subject to change as part of the Swift Package Manager
210210
review process.
211211

212212
If `--configuration-path` is specified, Swift Testing will open it for reading
213-
and attempt to decode its contents as JSON. If `--event-stream-output` is
213+
and attempt to decode its contents as JSON. If `--event-stream-output-path` is
214214
specified, Swift Testing will open it for writing and will write a sequence of
215215
[JSON Lines](https://jsonlines.org) to it representing the data and events
216216
produced by the test run. `--event-stream-version` determines the stable schema
217217
used for output; pass `0` to match the schema proposed in this document.
218218

219219
> [!NOTE]
220-
> If `--event-stream-output` is specified but `--event-stream-version` is not,
221-
> the format _currently_ used is based on direct JSON encodings of the internal
222-
> Swift structures used by Swift Testing. This format is necessary to support
223-
> Xcode 16 Beta 1. In the future, the default value of this argument will be
224-
> assumed to be `0` instead (i.e. the JSON schema will match what we are
225-
> proposing here.)
220+
> If `--event-stream-output-path` is specified but `--event-stream-version` is
221+
> not, the format _currently_ used is based on direct JSON encodings of the
222+
> internal Swift structures used by Swift Testing. This format is necessary to
223+
> support Xcode 16 Beta 1. In the future, the default value of this argument
224+
> will be assumed to equal the newest available JSON schema version (`0` as of
225+
> this document's acceptance, i.e. the JSON schema will match what we are
226+
> proposing here until a new schema supersedes it.)
227+
>
228+
> Tools authors that rely on the JSON schema are strongly advised to specify a
229+
> version rather than relying on this behavior to avoid breaking changes in the
230+
> future.
226231
227232
On platforms that support them, callers can use a named pipe with
228-
`--event-stream-output` to get live results back from the test run rather than
229-
needing to wait until the file is closed by the test process. Named pipes can be
230-
created on Darwin or Linux with the POSIX [`mkfifo()`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/mkfifo.2.html)
233+
`--event-stream-output-path` to get live results back from the test run rather
234+
than needing to wait until the file is closed by the test process. Named pipes
235+
can be created on Darwin or Linux with the POSIX [`mkfifo()`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/mkfifo.2.html)
231236
function or on Windows with the [`CreateNamedPipe()`](https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-createnamedpipew)
232237
function.
233238

@@ -278,8 +283,8 @@ public enum ABIv0 {
278283
/// using `dlsym()` or a platform equivalent.
279284
///
280285
/// The value of this property can be thought of as equivalent to
281-
/// `swift test --event-stream-output` except that, instead of streaming JSON
282-
/// records to a named pipe or file, it streams them to an in-process
286+
/// `swift test --event-stream-output-path` except that, instead of streaming
287+
/// JSON records to a named pipe or file, it streams them to an in-process
283288
/// callback.
284289
public static var entryPoint: EntryPoint { get }
285290
}

Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ extension ABIv0 {
4242
/// using `dlsym()` or a platform equivalent.
4343
///
4444
/// The value of this property can be thought of as equivalent to a call to
45-
/// `swift test --event-stream-output` except that, instead of streaming JSON
46-
/// records to a named pipe or file, it streams them to an in-process
45+
/// `swift test --event-stream-output-path` except that, instead of streaming
46+
/// JSON records to a named pipe or file, it streams them to an in-process
4747
/// callback.
4848
public static var entryPoint: EntryPoint {
4949
return { configurationJSON, recordHandler in

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public struct __CommandLineArguments_v0: Sendable {
200200
/// The value of the `--xunit-output` argument.
201201
public var xunitOutput: String?
202202

203-
/// The value of the `--event-stream-output` argument.
203+
/// The value of the `--event-stream-output-path` argument.
204204
///
205205
/// Data is written to this file in the [JSON Lines](https://jsonlines.org)
206206
/// text format. For each event handled by the resulting event handler, a JSON
@@ -215,7 +215,7 @@ public struct __CommandLineArguments_v0: Sendable {
215215
///
216216
/// The file is closed when this process terminates or the test run completes,
217217
/// whichever occurs first.
218-
public var eventStreamOutput: String?
218+
public var eventStreamOutputPath: String?
219219

220220
/// The version of the event stream schema to use when writing events to
221221
/// ``eventStreamOutput``.
@@ -252,7 +252,7 @@ extension __CommandLineArguments_v0: Codable {
252252
case quiet
253253
case _verbosity = "verbosity"
254254
case xunitOutput
255-
case eventStreamOutput
255+
case eventStreamOutputPath
256256
case eventStreamVersion
257257
case filter
258258
case skip
@@ -303,9 +303,9 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
303303
}
304304

305305
// Event stream output (experimental)
306-
if let eventOutputIndex = args.firstIndex(of: "--event-stream-output") ?? args.firstIndex(of: "--experimental-event-stream-output"),
306+
if let eventOutputIndex = args.firstIndex(of: "--event-stream-output-path") ?? args.firstIndex(of: "--experimental-event-stream-output"),
307307
!isLastArgument(at: eventOutputIndex) {
308-
result.eventStreamOutput = args[args.index(after: eventOutputIndex)]
308+
result.eventStreamOutputPath = args[args.index(after: eventOutputIndex)]
309309
}
310310
// Event stream output (experimental)
311311
if let eventOutputVersionIndex = args.firstIndex(of: "--event-stream-version") ?? args.firstIndex(of: "--experimental-event-stream-version"),
@@ -407,7 +407,7 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
407407

408408
#if canImport(Foundation)
409409
// Event stream output (experimental)
410-
if let eventStreamOutputPath = args.eventStreamOutput {
410+
if let eventStreamOutputPath = args.eventStreamOutputPath {
411411
let file = try FileHandle(forWritingAtPath: eventStreamOutputPath)
412412
let eventHandler = try eventHandlerForStreamingEvents(version: args.eventStreamVersion) { json in
413413
try? _writeJSONLine(json, to: file)

Tests/TestingTests/SwiftPMTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ struct SwiftPMTests {
207207
}
208208
}
209209

210-
@Test("--event-stream-output argument (writes to a stream and can be read back)",
210+
@Test("--event-stream-output-path argument (writes to a stream and can be read back)",
211211
arguments: [
212-
("--event-stream-output", "--event-stream-version", "0"),
212+
("--event-stream-output-path", "--event-stream-version", "0"),
213213
("--experimental-event-stream-output", "--experimental-event-stream-version", "0"),
214214
])
215215
func eventStreamOutput(outputArgumentName: String, versionArgumentName: String, version: String) async throws {

0 commit comments

Comments
 (0)