@@ -18,25 +18,24 @@ class ShellOutTests: XCTestCase {
18
18
XCTAssertEqual ( echo, " Hello world " )
19
19
}
20
20
21
- func testWithInlineArguments( ) throws {
22
- let echo = try shellOut ( to: " echo \" Hello world \" " )
23
- XCTAssertEqual ( echo, " Hello world " )
24
- }
25
-
26
21
func testSingleCommandAtPath( ) throws {
27
- try shellOut ( to: " echo \ "Hello \ " > \( NSTemporaryDirectory ( ) ) ShellOutTests-SingleCommand.txt " )
22
+ try shellOut ( to: " echo " , arguments : [ # "Hello" > \# ( NSTemporaryDirectory ( ) ) ShellOutTests-SingleCommand.txt"# ] )
28
23
29
- let textFileContent = try shellOut ( to: " cat ShellOutTests-SingleCommand.txt " ,
24
+ let textFileContent = try shellOut ( to: " cat " ,
25
+ arguments: [ " ShellOutTests-SingleCommand.txt " ] ,
30
26
at: NSTemporaryDirectory ( ) )
31
27
32
28
XCTAssertEqual ( textFileContent, " Hello " )
33
29
}
34
30
35
31
func testSingleCommandAtPathContainingSpace( ) throws {
36
- try shellOut ( to: " mkdir -p \" ShellOut Test Folder \" " , at: NSTemporaryDirectory ( ) )
37
- try shellOut ( to: " echo \" Hello \" > File " , at: NSTemporaryDirectory ( ) + " ShellOut Test Folder " )
32
+ try shellOut ( to: " mkdir " , arguments: [ " -p " , " ShellOut Test Folder " ] ,
33
+ at: NSTemporaryDirectory ( ) )
34
+ try shellOut ( to: " echo " , arguments: [ " Hello " , " > " , " File " ] ,
35
+ at: NSTemporaryDirectory ( ) + " ShellOut Test Folder " )
38
36
39
- let output = try shellOut ( to: " cat \( NSTemporaryDirectory ( ) ) ShellOut \\ Test \\ Folder/File " )
37
+ let output = try shellOut ( to: " cat " ,
38
+ arguments: [ " \( NSTemporaryDirectory ( ) ) ShellOut Test Folder/File " ] )
40
39
XCTAssertEqual ( output, " Hello " )
41
40
}
42
41
@@ -108,8 +107,8 @@ class ShellOutTests: XCTestCase {
108
107
func testGitCommands( ) throws {
109
108
// Setup & clear state
110
109
let tempFolderPath = NSTemporaryDirectory ( )
111
- try shellOut ( to: " rm -rf GitTestOrigin " , at: tempFolderPath)
112
- try shellOut ( to: " rm -rf GitTestClone " , at: tempFolderPath)
110
+ try shellOut ( to: " rm " , arguments : [ " -rf " , " GitTestOrigin " ] , at: tempFolderPath)
111
+ try shellOut ( to: " rm " , arguments : [ " -rf " , " GitTestClone " ] , at: tempFolderPath)
113
112
114
113
// Create a origin repository and make a commit with a file
115
114
let originPath = tempFolderPath + " /GitTestOrigin "
@@ -138,7 +137,9 @@ class ShellOutTests: XCTestCase {
138
137
func testSwiftPackageManagerCommands( ) throws {
139
138
// Setup & clear state
140
139
let tempFolderPath = NSTemporaryDirectory ( )
141
- try shellOut ( to: " rm -rf SwiftPackageManagerTest " , at: tempFolderPath)
140
+ try shellOut ( to: " rm " ,
141
+ arguments: [ " -rf " , " SwiftPackageManagerTest " ] ,
142
+ at: tempFolderPath)
142
143
try shellOut ( to: . createFolder( named: " SwiftPackageManagerTest " ) , at: tempFolderPath)
143
144
144
145
// Create a Swift package and verify that it has a Package.swift file
0 commit comments