@@ -286,6 +286,7 @@ class TestURL : XCTestCase {
286
286
static var gBaseCurrentWorkingDirectoryPath : String {
287
287
return FileManager . default. currentDirectoryPath
288
288
}
289
+ static var gSavedPath = " "
289
290
static var gRelativeOffsetFromBaseCurrentWorkingDirectory : UInt = 0
290
291
static let gFileExistsName = " TestCFURL_file_exists \( ProcessInfo . processInfo. globallyUniqueString) "
291
292
static let gFileDoesNotExistName = " TestCFURL_file_does_not_exist "
@@ -339,9 +340,8 @@ class TestURL : XCTestCase {
339
340
}
340
341
}
341
342
342
- #if os(Android)
343
- FileManager . default. changeCurrentDirectoryPath ( " /data/local/tmp " )
344
- #endif
343
+ TestURL . gSavedPath = FileManager . default. currentDirectoryPath
344
+ FileManager . default. changeCurrentDirectoryPath ( NSTemporaryDirectory ( ) )
345
345
346
346
let cwd = FileManager . default. currentDirectoryPath
347
347
let cwdURL = URL ( fileURLWithPath: cwd, isDirectory: true )
@@ -396,6 +396,8 @@ class TestURL : XCTestCase {
396
396
let lengthOfRelativePath = Int ( strlen ( TestURL . gFileDoesNotExistName) )
397
397
let relativePath = fileSystemRep. advanced ( by: Int ( TestURL . gRelativeOffsetFromBaseCurrentWorkingDirectory) )
398
398
XCTAssertTrue ( strncmp ( TestURL . gFileDoesNotExistName, relativePath, lengthOfRelativePath) == 0 , " fileSystemRepresentation of file path is wrong " )
399
+
400
+ FileManager . default. changeCurrentDirectoryPath ( TestURL . gSavedPath)
399
401
}
400
402
401
403
func test_fileURLWithPath_isDirectory( ) {
@@ -451,6 +453,8 @@ class TestURL : XCTestCase {
451
453
let lengthOfRelativePath = Int ( strlen ( TestURL . gFileDoesNotExistName) )
452
454
let relativePath = fileSystemRep. advanced ( by: Int ( TestURL . gRelativeOffsetFromBaseCurrentWorkingDirectory) )
453
455
XCTAssertTrue ( strncmp ( TestURL . gFileDoesNotExistName, relativePath, lengthOfRelativePath) == 0 , " fileSystemRepresentation of file path is wrong " )
456
+
457
+ FileManager . default. changeCurrentDirectoryPath ( TestURL . gSavedPath)
454
458
}
455
459
456
460
func test_URLByResolvingSymlinksInPath( ) {
0 commit comments