@@ -32,23 +32,23 @@ class ShellOutTests: XCTestCase {
32
32
}
33
33
34
34
func testWithoutArguments( ) throws {
35
- let uptime = try shellOut ( to: " uptime " . safe )
35
+ let uptime = try shellOut ( to: " uptime " . checked )
36
36
XCTAssertTrue ( uptime. contains ( " load average " ) )
37
37
}
38
38
39
39
func testWithArguments( ) throws {
40
- let echo = try shellOut ( to: " echo " . safe , arguments: [ " Hello world " . quoted] )
40
+ let echo = try shellOut ( to: " echo " . checked , arguments: [ " Hello world " . quoted] )
41
41
XCTAssertEqual ( echo, " Hello world " )
42
42
}
43
43
44
44
func testSingleCommandAtPath( ) throws {
45
45
try shellOut (
46
- to: " echo " . safe ,
46
+ to: " echo " . checked ,
47
47
arguments: [ #"Hello" > \#( NSTemporaryDirectory ( ) ) ShellOutTests-SingleCommand.txt"# . quoted]
48
48
)
49
49
50
50
let textFileContent = try shellOut (
51
- to: " cat " . safe ,
51
+ to: " cat " . checked ,
52
52
arguments: [ " ShellOutTests-SingleCommand.txt " . quoted] ,
53
53
at: NSTemporaryDirectory ( )
54
54
)
@@ -57,26 +57,26 @@ class ShellOutTests: XCTestCase {
57
57
}
58
58
59
59
func testSingleCommandAtPathContainingSpace( ) throws {
60
- try shellOut ( to: " mkdir " . safe ,
60
+ try shellOut ( to: " mkdir " . checked ,
61
61
arguments: [ " -p " . verbatim, " ShellOut Test Folder " . quoted] ,
62
62
at: NSTemporaryDirectory ( ) )
63
- try shellOut ( to: " echo " . safe , arguments: [ " Hello " , " > " , " File " ] . verbatim,
63
+ try shellOut ( to: " echo " . checked , arguments: [ " Hello " , " > " , " File " ] . verbatim,
64
64
at: NSTemporaryDirectory ( ) + " ShellOut Test Folder " )
65
65
66
66
let output = try shellOut (
67
- to: " cat " . safe ,
67
+ to: " cat " . checked ,
68
68
arguments: [ " \( NSTemporaryDirectory ( ) ) ShellOut Test Folder/File " . quoted] )
69
69
XCTAssertEqual ( output, " Hello " )
70
70
}
71
71
72
72
func testSingleCommandAtPathContainingTilde( ) throws {
73
- let homeContents = try shellOut ( to: " ls " . safe , at: " ~ " )
73
+ let homeContents = try shellOut ( to: " ls " . checked , at: " ~ " )
74
74
XCTAssertFalse ( homeContents. isEmpty)
75
75
}
76
76
77
77
func testThrowingError( ) {
78
78
do {
79
- try shellOut ( to: " cd " . safe , arguments: [ " notADirectory " . verbatim] )
79
+ try shellOut ( to: " cd " . checked , arguments: [ " notADirectory " . verbatim] )
80
80
XCTFail ( " Expected expression to throw " )
81
81
} catch let error as ShellOutError {
82
82
XCTAssertTrue ( error. message. contains ( " notADirectory " ) )
@@ -110,7 +110,7 @@ class ShellOutTests: XCTestCase {
110
110
111
111
func testCapturingOutputWithHandle( ) throws {
112
112
let pipe = Pipe ( )
113
- let output = try shellOut ( to: " echo " . safe ,
113
+ let output = try shellOut ( to: " echo " . checked ,
114
114
arguments: [ " Hello " . verbatim] ,
115
115
outputHandle: pipe. fileHandleForWriting)
116
116
let capturedData = pipe. fileHandleForReading. readDataToEndOfFile ( )
@@ -122,7 +122,7 @@ class ShellOutTests: XCTestCase {
122
122
let pipe = Pipe ( )
123
123
124
124
do {
125
- try shellOut ( to: " cd " . safe ,
125
+ try shellOut ( to: " cd " . checked ,
126
126
arguments: [ " notADirectory " . verbatim] ,
127
127
errorHandle: pipe. fileHandleForWriting)
128
128
XCTFail ( " Expected expression to throw " )
@@ -149,10 +149,10 @@ class ShellOutTests: XCTestCase {
149
149
func testGitCommands( ) throws {
150
150
// Setup & clear state
151
151
let tempFolderPath = NSTemporaryDirectory ( )
152
- try shellOut ( to: " rm " . safe ,
152
+ try shellOut ( to: " rm " . checked ,
153
153
arguments: [ " -rf " , " GitTestOrigin " ] . verbatim,
154
154
at: tempFolderPath)
155
- try shellOut ( to: " rm " . safe ,
155
+ try shellOut ( to: " rm " . checked ,
156
156
arguments: [ " -rf " , " GitTestClone " ] . verbatim,
157
157
at: tempFolderPath)
158
158
@@ -183,7 +183,7 @@ class ShellOutTests: XCTestCase {
183
183
func testSwiftPackageManagerCommands( ) throws {
184
184
// Setup & clear state
185
185
let tempFolderPath = NSTemporaryDirectory ( )
186
- try shellOut ( to: " rm " . safe ,
186
+ try shellOut ( to: " rm " . checked ,
187
187
arguments: [ " -rf " , " SwiftPackageManagerTest " ] . verbatim,
188
188
at: tempFolderPath)
189
189
try shellOut ( to: . createFolder( named: " SwiftPackageManagerTest " ) , at: tempFolderPath)
@@ -196,22 +196,22 @@ class ShellOutTests: XCTestCase {
196
196
// Build the package and verify that there's a .build folder
197
197
try shellOut ( to: . buildSwiftPackage( ) , at: packagePath)
198
198
XCTAssertTrue (
199
- try shellOut ( to: " ls " . safe , arguments: [ " -a " . verbatim] , at: packagePath) . contains ( " .build " )
199
+ try shellOut ( to: " ls " . checked , arguments: [ " -a " . verbatim] , at: packagePath) . contains ( " .build " )
200
200
)
201
201
202
202
// Generate an Xcode project
203
203
try shellOut ( to: . generateSwiftPackageXcodeProject( ) , at: packagePath)
204
204
XCTAssertTrue (
205
- try shellOut ( to: " ls " . safe , arguments: [ " -a " . verbatim] , at: packagePath)
205
+ try shellOut ( to: " ls " . checked , arguments: [ " -a " . verbatim] , at: packagePath)
206
206
. contains ( " SwiftPackageManagerTest.xcodeproj " )
207
207
)
208
208
}
209
209
210
210
func testArgumentQuoting( ) throws {
211
- XCTAssertEqual ( try shellOut ( to: " echo " . safe ,
211
+ XCTAssertEqual ( try shellOut ( to: " echo " . checked ,
212
212
arguments: [ " foo ; echo bar " . quoted] ) ,
213
213
" foo ; echo bar " )
214
- XCTAssertEqual ( try shellOut ( to: " echo " . safe ,
214
+ XCTAssertEqual ( try shellOut ( to: " echo " . checked ,
215
215
arguments: [ " foo ; echo bar " . verbatim] ) ,
216
216
" foo \n bar " )
217
217
}
0 commit comments