@@ -24,7 +24,7 @@ final class ShellTests: XCTestCase {
24
24
super. tearDown ( )
25
25
}
26
26
27
- func testExecuteCommandWithShellInitialization( ) {
27
+ func testExecuteCommandWithShellInitialization( ) throws {
28
28
let command = " echo $STATE "
29
29
let environmentVariables = [ " STATE " : " Testing " ]
30
30
let shell : Shell = . bash
@@ -45,17 +45,13 @@ final class ShellTests: XCTestCase {
45
45
46
46
// Additional assertion to check output
47
47
let outputData = outputPipe. fileHandleForReading. readDataToEndOfFile ( )
48
- if let outputString = String (
49
- bytes: outputData,
50
- encoding: . utf8
51
- ) ? . trimmingCharacters ( in: . whitespacesAndNewlines) {
52
- XCTAssertTrue ( outputString. contains ( " Testing " ) )
53
- } else {
54
- XCTFail ( " Failed to decode output data " )
55
- }
48
+ let outputString = try XCTUnwrap (
49
+ String ( bytes: outputData, encoding: . utf8) ? . trimmingCharacters ( in: . whitespacesAndNewlines)
50
+ )
51
+ XCTAssertTrue ( outputString. contains ( " Testing " ) )
56
52
}
57
53
58
- func testExecuteCommandWithShellOutput( ) {
54
+ func testExecuteCommandWithShellOutput( ) throws {
59
55
let command = " echo $STATE "
60
56
let environmentVariables = [ " STATE " : " Testing " ]
61
57
let shell : Shell = . bash
@@ -69,14 +65,10 @@ final class ShellTests: XCTestCase {
69
65
) )
70
66
71
67
let outputData = outputPipe. fileHandleForReading. readDataToEndOfFile ( )
72
- if let outputString = String (
73
- bytes: outputData,
74
- encoding: . utf8
75
- ) ? . trimmingCharacters ( in: . whitespacesAndNewlines) {
76
- XCTAssertTrue ( outputString. contains ( " Testing " ) )
77
- } else {
78
- XCTFail ( " Failed to decode output data " )
79
- }
68
+ let outputString = try XCTUnwrap (
69
+ String ( bytes: outputData, encoding: . utf8) ? . trimmingCharacters ( in: . whitespacesAndNewlines)
70
+ )
71
+ XCTAssertTrue ( outputString. contains ( " Testing " ) )
80
72
}
81
73
82
74
func testExecuteCommandWithExecutableOverrideAttempt( ) {
0 commit comments