Skip to content

Commit 7928f39

Browse files
authored
Rename ExecutionResult to ExecutionOutcome; rename CollectedResult to ExecutionRecord (#225)
1 parent b1153d3 commit 7928f39

6 files changed

Lines changed: 51 additions & 51 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ To experiment with the `SubprocessSpan` trait, Swift 6.2 is required. Currently,
4444

4545
### Run and Asynchronously Collect Output
4646

47-
The easiest way to spawn a process with `Subprocess` is to simply run it and await its `CollectedResult`:
47+
The easiest way to spawn a process with `Subprocess` is to simply run it and await its `ExecutionRecord`:
4848

4949
```swift
5050
import Subprocess

Sources/Subprocess/API.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import SystemPackage
2828
/// - input: The input to send to the executable.
2929
/// - output: The method to use for redirecting the standard output.
3030
/// - error: The method to use for redirecting the standard error.
31-
/// - Returns: a `CollectedResult` containing the result of the run.
31+
/// - Returns: a `ExecutionRecord` containing the result of the run.
3232
public func run<
3333
Input: InputProtocol,
3434
Output: OutputProtocol,
@@ -42,7 +42,7 @@ public func run<
4242
input: Input = .none,
4343
output: Output,
4444
error: Error = .discarded
45-
) async throws -> CollectedResult<Output, Error> {
45+
) async throws -> ExecutionRecord<Output, Error> {
4646
let configuration = Configuration(
4747
executable: executable,
4848
arguments: arguments,
@@ -70,7 +70,7 @@ public func run<
7070
/// - input: span to write to subprocess' standard input.
7171
/// - output: The method to use for redirecting the standard output.
7272
/// - error: The method to use for redirecting the standard error.
73-
/// - Returns: a CollectedResult containing the result of the run.
73+
/// - Returns: a ExecutionRecord containing the result of the run.
7474
public func run<
7575
InputElement: BitwiseCopyable,
7676
Output: OutputProtocol,
@@ -84,7 +84,7 @@ public func run<
8484
input: borrowing Span<InputElement>,
8585
output: Output,
8686
error: Error = .discarded
87-
) async throws -> CollectedResult<Output, Error> {
87+
) async throws -> ExecutionRecord<Output, Error> {
8888
let configuration = Configuration(
8989
executable: executable,
9090
arguments: arguments,
@@ -133,7 +133,7 @@ public func run<
133133
error: Error = .discarded,
134134
isolation: isolated (any Actor)? = #isolation,
135135
body: ((Execution) async throws -> Result)
136-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
136+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
137137
let configuration = Configuration(
138138
executable: executable,
139139
arguments: arguments,
@@ -180,7 +180,7 @@ public func run<Result, Input: InputProtocol, Error: ErrorOutputProtocol>(
180180
preferredBufferSize: Int? = nil,
181181
isolation: isolated (any Actor)? = #isolation,
182182
body: ((Execution, AsyncBufferSequence) async throws -> Result)
183-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
183+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
184184
let configuration = Configuration(
185185
executable: executable,
186186
arguments: arguments,
@@ -227,7 +227,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
227227
preferredBufferSize: Int? = nil,
228228
isolation: isolated (any Actor)? = #isolation,
229229
body: ((Execution, AsyncBufferSequence) async throws -> Result)
230-
) async throws -> ExecutionResult<Result> where Output.OutputType == Void {
230+
) async throws -> ExecutionOutcome<Result> where Output.OutputType == Void {
231231
let configuration = Configuration(
232232
executable: executable,
233233
arguments: arguments,
@@ -272,7 +272,7 @@ public func run<Result, Error: ErrorOutputProtocol>(
272272
preferredBufferSize: Int? = nil,
273273
isolation: isolated (any Actor)? = #isolation,
274274
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
275-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
275+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
276276
let configuration = Configuration(
277277
executable: executable,
278278
arguments: arguments,
@@ -316,7 +316,7 @@ public func run<Result, Output: OutputProtocol>(
316316
preferredBufferSize: Int? = nil,
317317
isolation: isolated (any Actor)? = #isolation,
318318
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
319-
) async throws -> ExecutionResult<Result> where Output.OutputType == Void {
319+
) async throws -> ExecutionOutcome<Result> where Output.OutputType == Void {
320320
let configuration = Configuration(
321321
executable: executable,
322322
arguments: arguments,
@@ -366,7 +366,7 @@ public func run<Result>(
366366
AsyncBufferSequence
367367
) async throws -> Result
368368
)
369-
) async throws -> ExecutionResult<Result> {
369+
) async throws -> ExecutionOutcome<Result> {
370370
let configuration = Configuration(
371371
executable: executable,
372372
arguments: arguments,
@@ -386,13 +386,13 @@ public func run<Result>(
386386

387387
#if SubprocessSpan
388388
/// Run an executable with given configuration asynchronously and returns
389-
/// a `CollectedResult` containing the output of the child process.
389+
/// a `ExecutionRecord` containing the output of the child process.
390390
/// - Parameters:
391391
/// - configuration: The configuration to run.
392392
/// - input: span to write to subprocess' standard input.
393393
/// - output: The method to use for redirecting the standard output.
394394
/// - error: The method to use for redirecting the standard error.
395-
/// - Returns a CollectedResult containing the result of the run.
395+
/// - Returns a ExecutionRecord containing the result of the run.
396396
public func run<
397397
InputElement: BitwiseCopyable,
398398
Output: OutputProtocol,
@@ -402,7 +402,7 @@ public func run<
402402
input: borrowing Span<InputElement>,
403403
output: Output,
404404
error: Error = .discarded
405-
) async throws -> CollectedResult<Output, Error> {
405+
) async throws -> ExecutionRecord<Output, Error> {
406406
typealias RunResult = (
407407
processIdentifier: ProcessIdentifier,
408408
standardOutput: Output.OutputType,
@@ -437,7 +437,7 @@ public func run<
437437
)
438438
}
439439

440-
return CollectedResult(
440+
return ExecutionRecord(
441441
processIdentifier: result.value.processIdentifier,
442442
terminationStatus: result.terminationStatus,
443443
standardOutput: result.value.standardOutput,
@@ -447,13 +447,13 @@ public func run<
447447
#endif
448448

449449
/// Run a `Configuration` asynchronously and returns
450-
/// a `CollectedResult` containing the output of the child process.
450+
/// a `ExecutionRecord` containing the output of the child process.
451451
/// - Parameters:
452452
/// - configuration: The `Subprocess` configuration to run.
453453
/// - input: The input to send to the executable.
454454
/// - output: The method to use for redirecting the standard output.
455455
/// - error: The method to use for redirecting the standard error.
456-
/// - Returns: a `CollectedResult` containing the result of the run.
456+
/// - Returns: a `ExecutionRecord` containing the result of the run.
457457
public func run<
458458
Input: InputProtocol,
459459
Output: OutputProtocol,
@@ -463,7 +463,7 @@ public func run<
463463
input: Input = .none,
464464
output: Output,
465465
error: Error = .discarded
466-
) async throws -> CollectedResult<Output, Error> {
466+
) async throws -> ExecutionRecord<Output, Error> {
467467
typealias RunResult = (
468468
processIdentifier: ProcessIdentifier,
469469
standardOutput: Output.OutputType,
@@ -541,7 +541,7 @@ public func run<
541541
}
542542
}
543543

544-
return CollectedResult(
544+
return ExecutionRecord(
545545
processIdentifier: result.value.processIdentifier,
546546
terminationStatus: result.terminationStatus,
547547
standardOutput: result.value.standardOutput,
@@ -572,7 +572,7 @@ public func run<
572572
error: Error = .discarded,
573573
isolation: isolated (any Actor)? = #isolation,
574574
body: ((Execution) async throws -> Result)
575-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
575+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
576576
let inputPipe = try input.createPipe()
577577
let outputPipe = try output.createPipe()
578578
let errorPipe = try error.createPipe(from: outputPipe)
@@ -630,7 +630,7 @@ public func run<
630630
preferredBufferSize: Int? = nil,
631631
isolation: isolated (any Actor)? = #isolation,
632632
body: ((Execution, AsyncBufferSequence) async throws -> Result)
633-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
633+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
634634
let output = SequenceOutput()
635635
let inputPipe = try input.createPipe()
636636
let outputPipe = try output.createPipe()
@@ -692,7 +692,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
692692
preferredBufferSize: Int? = nil,
693693
isolation: isolated (any Actor)? = #isolation,
694694
body: ((Execution, AsyncBufferSequence) async throws -> Result)
695-
) async throws -> ExecutionResult<Result> where Output.OutputType == Void {
695+
) async throws -> ExecutionOutcome<Result> where Output.OutputType == Void {
696696
let error = SequenceOutput()
697697

698698
return try await configuration.run(
@@ -750,7 +750,7 @@ public func run<Result, Error: ErrorOutputProtocol>(
750750
preferredBufferSize: Int? = nil,
751751
isolation: isolated (any Actor)? = #isolation,
752752
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
753-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
753+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
754754
let input = CustomWriteInput()
755755
let output = SequenceOutput()
756756
let inputPipe = try input.createPipe()
@@ -793,7 +793,7 @@ public func run<Result, Output: OutputProtocol>(
793793
preferredBufferSize: Int? = nil,
794794
isolation: isolated (any Actor)? = #isolation,
795795
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
796-
) async throws -> ExecutionResult<Result> where Output.OutputType == Void {
796+
) async throws -> ExecutionOutcome<Result> where Output.OutputType == Void {
797797
let input = CustomWriteInput()
798798
let error = SequenceOutput()
799799

@@ -838,7 +838,7 @@ public func run<Result>(
838838
AsyncBufferSequence
839839
) async throws -> Result
840840
)
841-
) async throws -> ExecutionResult<Result> {
841+
) async throws -> ExecutionOutcome<Result> {
842842
let input = CustomWriteInput()
843843
let output = SequenceOutput()
844844
let error = SequenceOutput()

Sources/Subprocess/Configuration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public struct Configuration: Sendable {
9999
consuming IOChannel?
100100
) async throws -> Result
101101
)
102-
) async throws -> ExecutionResult<Result> {
102+
) async throws -> ExecutionOutcome<Result> {
103103
let spawnResults = try await self.spawn(
104104
withInput: input,
105105
outputPipe: output,
@@ -115,7 +115,7 @@ public struct Configuration: Sendable {
115115
execution.processIdentifier.close()
116116
}
117117

118-
return try await withAsyncTaskCleanupHandler { () throws -> ExecutionResult<Result> in
118+
return try await withAsyncTaskCleanupHandler { () throws -> ExecutionOutcome<Result> in
119119
let inputIO = _spawnResult.inputWriteEnd()
120120
let outputIO = _spawnResult.outputReadEnd()
121121
let errorIO = _spawnResult.errorReadEnd()
@@ -138,7 +138,7 @@ public struct Configuration: Sendable {
138138
for: execution.processIdentifier
139139
)
140140

141-
return ExecutionResult(
141+
return ExecutionOutcome(
142142
terminationStatus: terminationStatus,
143143
value: try result.get()
144144
)

Sources/Subprocess/Result.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SystemPackage
2020
/// A simple wrapper around the generic result returned by the
2121
/// `run` closure with the corresponding termination status of
2222
/// the child process.
23-
public struct ExecutionResult<Result: Sendable>: Sendable {
23+
public struct ExecutionOutcome<Result: Sendable>: Sendable {
2424
/// The termination status of the child process
2525
public let terminationStatus: TerminationStatus
2626
/// The result returned by the closure passed to `.run` methods
@@ -34,7 +34,7 @@ public struct ExecutionResult<Result: Sendable>: Sendable {
3434

3535
/// The result of a subprocess execution with its collected
3636
/// standard output and standard error.
37-
public struct CollectedResult<
37+
public struct ExecutionRecord<
3838
Output: OutputProtocol,
3939
Error: OutputProtocol
4040
>: Sendable {
@@ -60,18 +60,18 @@ public struct CollectedResult<
6060
}
6161
}
6262

63-
// MARK: - CollectedResult Conformances
63+
// MARK: - ExecutionRecord Conformances
6464

65-
extension CollectedResult: Equatable where Output.OutputType: Equatable, Error.OutputType: Equatable {}
65+
extension ExecutionRecord: Equatable where Output.OutputType: Equatable, Error.OutputType: Equatable {}
6666

67-
extension CollectedResult: Hashable where Output.OutputType: Hashable, Error.OutputType: Hashable {}
67+
extension ExecutionRecord: Hashable where Output.OutputType: Hashable, Error.OutputType: Hashable {}
6868

69-
extension CollectedResult: CustomStringConvertible
69+
extension ExecutionRecord: CustomStringConvertible
7070
where Output.OutputType: CustomStringConvertible, Error.OutputType: CustomStringConvertible {
7171
/// A textual representation of the collected result.
7272
public var description: String {
7373
return """
74-
CollectedResult(
74+
ExecutionRecord(
7575
processIdentifier: \(self.processIdentifier),
7676
terminationStatus: \(self.terminationStatus.description),
7777
standardOutput: \(self.standardOutput.description)
@@ -81,12 +81,12 @@ where Output.OutputType: CustomStringConvertible, Error.OutputType: CustomString
8181
}
8282
}
8383

84-
extension CollectedResult: CustomDebugStringConvertible
84+
extension ExecutionRecord: CustomDebugStringConvertible
8585
where Output.OutputType: CustomDebugStringConvertible, Error.OutputType: CustomDebugStringConvertible {
8686
/// A debug-oriented textual representation of the collected result.
8787
public var debugDescription: String {
8888
return """
89-
CollectedResult(
89+
ExecutionRecord(
9090
processIdentifier: \(self.processIdentifier),
9191
terminationStatus: \(self.terminationStatus.description),
9292
standardOutput: \(self.standardOutput.debugDescription)
@@ -96,28 +96,28 @@ where Output.OutputType: CustomDebugStringConvertible, Error.OutputType: CustomD
9696
}
9797
}
9898

99-
// MARK: - ExecutionResult Conformances
100-
extension ExecutionResult: Equatable where Result: Equatable {}
99+
// MARK: - ExecutionOutcome Conformances
100+
extension ExecutionOutcome: Equatable where Result: Equatable {}
101101

102-
extension ExecutionResult: Hashable where Result: Hashable {}
102+
extension ExecutionOutcome: Hashable where Result: Hashable {}
103103

104-
extension ExecutionResult: CustomStringConvertible where Result: CustomStringConvertible {
104+
extension ExecutionOutcome: CustomStringConvertible where Result: CustomStringConvertible {
105105
/// A textual representation of the execution result.
106106
public var description: String {
107107
return """
108-
ExecutionResult(
108+
ExecutionOutcome(
109109
terminationStatus: \(self.terminationStatus.description),
110110
value: \(self.value.description)
111111
)
112112
"""
113113
}
114114
}
115115

116-
extension ExecutionResult: CustomDebugStringConvertible where Result: CustomDebugStringConvertible {
116+
extension ExecutionOutcome: CustomDebugStringConvertible where Result: CustomDebugStringConvertible {
117117
/// A debug-oriented textual representation of this execution result.
118118
public var debugDescription: String {
119119
return """
120-
ExecutionResult(
120+
ExecutionOutcome(
121121
terminationStatus: \(self.terminationStatus.debugDescription),
122122
value: \(self.value.debugDescription)
123123
)

Tests/SubprocessTests/IntegrationTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,7 @@ func _run<
26322632
input: Input,
26332633
output: Output,
26342634
error: Error
2635-
) async throws -> CollectedResult<Output, Error> {
2635+
) async throws -> ExecutionRecord<Output, Error> {
26362636
return try await Subprocess.run(
26372637
testSetup.executable,
26382638
arguments: testSetup.arguments,
@@ -2655,7 +2655,7 @@ func _run<
26552655
input: borrowing Span<InputElement>,
26562656
output: Output,
26572657
error: Error
2658-
) async throws -> CollectedResult<Output, Error> {
2658+
) async throws -> ExecutionRecord<Output, Error> {
26592659
return try await Subprocess.run(
26602660
testSetup.executable,
26612661
arguments: testSetup.arguments,
@@ -2678,7 +2678,7 @@ func _run<
26782678
error: Error,
26792679
preferredBufferSize: Int? = nil,
26802680
body: ((Execution, AsyncBufferSequence) async throws -> Result)
2681-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
2681+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
26822682
return try await Subprocess.run(
26832683
setup.executable,
26842684
arguments: setup.arguments,
@@ -2698,7 +2698,7 @@ func _run<
26982698
_ setup: TestSetup,
26992699
error: Error,
27002700
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
2701-
) async throws -> ExecutionResult<Result> where Error.OutputType == Void {
2701+
) async throws -> ExecutionOutcome<Result> where Error.OutputType == Void {
27022702
return try await Subprocess.run(
27032703
setup.executable,
27042704
arguments: setup.arguments,
@@ -2716,7 +2716,7 @@ func _run<
27162716
_ setup: TestSetup,
27172717
output: Output,
27182718
body: ((Execution, StandardInputWriter, AsyncBufferSequence) async throws -> Result)
2719-
) async throws -> ExecutionResult<Result> where Output.OutputType == Void {
2719+
) async throws -> ExecutionOutcome<Result> where Output.OutputType == Void {
27202720
return try await Subprocess.run(
27212721
setup.executable,
27222722
arguments: setup.arguments,
@@ -2730,7 +2730,7 @@ func _run<
27302730
func _run<Result>(
27312731
_ setup: TestSetup,
27322732
body: ((Execution, StandardInputWriter, AsyncBufferSequence, AsyncBufferSequence) async throws -> Result)
2733-
) async throws -> ExecutionResult<Result> {
2733+
) async throws -> ExecutionOutcome<Result> {
27342734
return try await Subprocess.run(
27352735
setup.executable,
27362736
arguments: setup.arguments,

0 commit comments

Comments
 (0)