@@ -16,9 +16,9 @@ class TestProcess : XCTestCase {
16
16
process. executableURL = executableURL
17
17
} else {
18
18
// Fallback on earlier versions
19
- process. launchPath = executableURL. path
19
+ process. executableURL = executableURL. path
20
20
}
21
- XCTAssertEqual ( executableURL. path, process. launchPath )
21
+ XCTAssertEqual ( executableURL. path, process. executableURL )
22
22
process. arguments = [ " --exit " , " 0 " ]
23
23
try process. run ( )
24
24
process. waitUntilExit ( )
@@ -123,7 +123,7 @@ class TestProcess : XCTestCase {
123
123
return
124
124
}
125
125
126
- XCTAssertEqual ( string. trimmingCharacters ( in: CharacterSet ( [ " \n " , " \r " ] ) ) , FileManager . default. currentDirectoryPath )
126
+ XCTAssertEqual ( string. trimmingCharacters ( in: CharacterSet ( [ " \n " , " \r " ] ) ) , FileManager . default. currentDirectoryURL )
127
127
}
128
128
129
129
func test_pipe_stderr( ) throws {
@@ -208,7 +208,7 @@ class TestProcess : XCTestCase {
208
208
XCTFail ( " Could not read stdout " )
209
209
return
210
210
}
211
- XCTAssertEqual ( string. trimmingCharacters ( in: CharacterSet ( [ " \r " , " \n " ] ) ) , FileManager . default. currentDirectoryPath )
211
+ XCTAssertEqual ( string. trimmingCharacters ( in: CharacterSet ( [ " \r " , " \n " ] ) ) , FileManager . default. currentDirectoryURL )
212
212
}
213
213
214
214
func test_passthrough_environment( ) {
@@ -260,7 +260,7 @@ class TestProcess : XCTestCase {
260
260
func test_current_working_directory( ) throws {
261
261
let tmpDir = { ( ) -> String in
262
262
// NSTemporaryDirectory might return a final slash, but
263
- // FileManager.currentDirectoryPath seems to avoid it.
263
+ // FileManager.currentDirectoryURL seems to avoid it.
264
264
var dir = NSTemporaryDirectory ( )
265
265
if ( dir. hasSuffix ( " / " ) && dir != " / " ) || dir. hasSuffix ( " \\ " ) {
266
266
dir. removeLast ( )
@@ -269,7 +269,7 @@ class TestProcess : XCTestCase {
269
269
} ( )
270
270
271
271
let fm = FileManager . default
272
- let previousWorkingDirectory = fm. currentDirectoryPath
272
+ let previousWorkingDirectory = fm. currentDirectoryURL
273
273
XCTAssertNotEqual ( previousWorkingDirectory. standardizePath ( ) , tmpDir)
274
274
275
275
// Test that getcwd() returns the currentDirectoryPath
@@ -285,7 +285,7 @@ class TestProcess : XCTestCase {
285
285
do {
286
286
let ( pwd, _) = try runTask ( [ xdgTestHelperURL ( ) . path, " --echo-PWD " ] , currentDirectoryPath: tmpDir)
287
287
// Check the sub-process used the correct directory
288
- let cwd = FileManager . default. currentDirectoryPath . standardizePath ( )
288
+ let cwd = FileManager . default. currentDirectoryURL . standardizePath ( )
289
289
XCTAssertNotEqual ( cwd, tmpDir)
290
290
XCTAssertNotEqual ( pwd. trimmingCharacters ( in: . newlines) . standardizePath ( ) , tmpDir)
291
291
} catch {
@@ -314,12 +314,12 @@ class TestProcess : XCTestCase {
314
314
XCTFail ( " Test failed: \( error) " )
315
315
}
316
316
317
- XCTAssertEqual ( previousWorkingDirectory, fm. currentDirectoryPath )
317
+ XCTAssertEqual ( previousWorkingDirectory, fm. currentDirectoryURL )
318
318
}
319
319
320
320
func test_run( ) {
321
321
let fm = FileManager . default
322
- let cwd = fm. currentDirectoryPath
322
+ let cwd = fm. currentDirectoryURL
323
323
324
324
do {
325
325
let process = try Process . run ( xdgTestHelperURL ( ) , arguments: [ " --exit " , " 123 " ] , terminationHandler: nil )
@@ -329,7 +329,7 @@ class TestProcess : XCTestCase {
329
329
} catch {
330
330
XCTFail ( " Cant execute \( xdgTestHelperURL ( ) . path) : \( error) " )
331
331
}
332
- XCTAssertEqual ( fm. currentDirectoryPath , cwd)
332
+ XCTAssertEqual ( fm. currentDirectoryURL , cwd)
333
333
334
334
do {
335
335
// Check running the process twice throws an error.
@@ -353,7 +353,7 @@ class TestProcess : XCTestCase {
353
353
process. currentDirectoryURL = URL ( fileURLWithPath: " /.../_no_such_directory " , isDirectory: true )
354
354
XCTAssertThrowsError ( try process. run ( ) )
355
355
}
356
- XCTAssertEqual ( fm. currentDirectoryPath , cwd)
356
+ XCTAssertEqual ( fm. currentDirectoryURL , cwd)
357
357
358
358
do {
359
359
let process = Process ( )
@@ -362,7 +362,7 @@ class TestProcess : XCTestCase {
362
362
process. currentDirectoryURL = URL ( fileURLWithPath: NSTemporaryDirectory ( ) )
363
363
XCTAssertThrowsError ( try process. run ( ) )
364
364
}
365
- XCTAssertEqual ( fm. currentDirectoryPath , cwd)
365
+ XCTAssertEqual ( fm. currentDirectoryURL , cwd)
366
366
fm. changeCurrentDirectoryPath ( cwd)
367
367
}
368
368
@@ -599,7 +599,7 @@ class TestProcess : XCTestCase {
599
599
XCTAssertNotNil ( process. currentDirectoryURL)
600
600
601
601
// Test currentDirectoryURL cannot be set to nil even though it is a URL?
602
- let cwd = URL ( fileURLWithPath: FileManager . default. currentDirectoryPath , isDirectory: true )
602
+ let cwd = URL ( fileURLWithPath: FileManager . default. currentDirectoryURL , isDirectory: true )
603
603
process. currentDirectoryURL = nil
604
604
XCTAssertNotNil ( process. currentDirectoryURL)
605
605
XCTAssertEqual ( process. currentDirectoryURL, cwd)
@@ -609,7 +609,7 @@ class TestProcess : XCTestCase {
609
609
XCTAssertEqual ( aFileURL. path, " /a_file " )
610
610
process. currentDirectoryURL = aFileURL
611
611
XCTAssertNotEqual ( process. currentDirectoryURL, aFileURL)
612
- XCTAssertEqual ( process. currentDirectoryPath , " /a_file " )
612
+ XCTAssertEqual ( process. currentDirectoryURL , " /a_file " )
613
613
XCTAssertTrue ( try XCTUnwrap ( process. currentDirectoryURL) . hasDirectoryPath)
614
614
XCTAssertEqual ( try XCTUnwrap ( process. currentDirectoryURL) . absoluteString, " file:///a_file/ " )
615
615
@@ -618,15 +618,15 @@ class TestProcess : XCTestCase {
618
618
XCTAssertEqual ( aDirURL. path, " /a_dir " )
619
619
process. currentDirectoryURL = aDirURL
620
620
XCTAssertEqual ( process. currentDirectoryURL, aDirURL)
621
- XCTAssertEqual ( process. currentDirectoryPath , " /a_dir " )
621
+ XCTAssertEqual ( process. currentDirectoryURL , " /a_dir " )
622
622
XCTAssertTrue ( try XCTUnwrap ( process. currentDirectoryURL) . hasDirectoryPath)
623
623
XCTAssertEqual ( try XCTUnwrap ( process. currentDirectoryURL) . absoluteString, " file:///a_dir/ " )
624
624
625
- process. currentDirectoryPath = " "
626
- XCTAssertEqual ( process. currentDirectoryPath , " " )
625
+ process. currentDirectoryURL = " "
626
+ XCTAssertEqual ( process. currentDirectoryURL , " " )
627
627
XCTAssertNil ( process. currentDirectoryURL)
628
628
process. currentDirectoryURL = nil
629
- XCTAssertEqual ( process. currentDirectoryPath , cwd. path)
629
+ XCTAssertEqual ( process. currentDirectoryURL , cwd. path)
630
630
631
631
632
632
process. executableURL = URL ( fileURLWithPath: " /some_file_that_doesnt_exist " , isDirectory: false )
@@ -654,8 +654,8 @@ class TestProcess : XCTestCase {
654
654
// The closed thing is %CD% which is a property of the shell rather
655
655
// than the environment. Simply ignore this test on Windows.
656
656
#if !os(Windows)
657
- XCTAssertNotEqual ( " / " , FileManager . default. currentDirectoryPath )
658
- XCTAssertNotEqual ( FileManager . default. currentDirectoryPath , " / " )
657
+ XCTAssertNotEqual ( " / " , FileManager . default. currentDirectoryURL )
658
+ XCTAssertNotEqual ( FileManager . default. currentDirectoryURL , " / " )
659
659
let ( stdout, _) = try runTask ( [ xdgTestHelperURL ( ) . path, " --echo-PWD " ] , currentDirectoryPath: " / " )
660
660
let directory = stdout. trimmingCharacters ( in: CharacterSet ( [ " \n " , " \r " ] ) )
661
661
XCTAssertEqual ( directory, ProcessInfo . processInfo. environment [ " PWD " ] )
@@ -667,7 +667,7 @@ class TestProcess : XCTestCase {
667
667
let process = Process ( )
668
668
process. executableURL = xdgTestHelperURL ( )
669
669
process. arguments = [ " --getcwd " ]
670
- process. currentDirectoryPath = " "
670
+ process. currentDirectoryURL = " "
671
671
672
672
let stdoutPipe = Pipe ( )
673
673
process. standardOutput = stdoutPipe
@@ -688,7 +688,7 @@ class TestProcess : XCTestCase {
688
688
throw Error . UnicodeDecodingError ( stdoutData)
689
689
}
690
690
let directory = stdout. trimmingCharacters ( in: CharacterSet ( [ " \n " , " \r " ] ) )
691
- XCTAssertEqual ( directory, FileManager . default. currentDirectoryPath )
691
+ XCTAssertEqual ( directory, FileManager . default. currentDirectoryURL )
692
692
} catch {
693
693
XCTFail ( String ( describing: error) )
694
694
}
@@ -800,7 +800,7 @@ class TestProcess : XCTestCase {
800
800
do {
801
801
let data = try XCTUnwrap ( pipe3. fileHandleForReading. readToEnd ( ) )
802
802
let pwd = String . init ( decoding: data, as: UTF8 . self) . trimmingCharacters ( in: CharacterSet ( [ " \n " , " \r " ] ) )
803
- XCTAssertEqual ( pwd, FileManager . default. currentDirectoryPath . standardizePath ( ) )
803
+ XCTAssertEqual ( pwd, FileManager . default. currentDirectoryURL . standardizePath ( ) )
804
804
} catch {
805
805
XCTFail ( " \( error) " )
806
806
}
@@ -971,7 +971,7 @@ internal func runTask(_ arguments: [String], environment: [String: String]? = ni
971
971
let process = Process ( )
972
972
973
973
var arguments = arguments
974
- process. launchPath = arguments. removeFirst ( )
974
+ process. executableURL = arguments. removeFirst ( )
975
975
process. arguments = arguments
976
976
// Darwin Foundation doesnt allow .environment to be set to nil although the documentation
977
977
// says it is an optional. https://developer.apple.com/documentation/foundation/process/1409412-environment
0 commit comments