Skip to content

Commit 9efa6be

Browse files
authored
Tests: make test_mountedVoumeURLs more robust (#3048)
Rather than creating a temporary directory, locate the application support directory. The temporary directory may be created under a root that that is not an actual volume, but rather an aliased mountpoint. This is the case on the CI hosts where `T:` is a path substitution rather than an actual disk volume.
1 parent d7d5710 commit 9efa6be

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Tests/Foundation/Tests/TestFileManager.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,14 @@ class TestFileManager : XCTestCase {
10801080
}
10811081
XCTAssertNotEqual(0, volumes.count)
10821082
#if os(Windows)
1083-
let url = URL(fileURLWithPath: String(NSTemporaryDirectory().prefix(3)))
1084-
XCTAssertTrue(volumes.contains(url))
1083+
guard let url: URL = FileManager.default.urls(for: .applicationSupportDirectory, in: .localDomainMask).first else {
1084+
XCTFail("unable to query a system directory")
1085+
return
1086+
}
1087+
let root: String = url.withUnsafeFileSystemRepresentation {
1088+
String(String(cString: $0!).prefix(3))
1089+
}
1090+
XCTAssertTrue(volumes.contains(URL(fileURLWithPath: root)))
10851091
#else
10861092
XCTAssertTrue(volumes.contains(URL(fileURLWithPath: "/")))
10871093
#endif

0 commit comments

Comments
 (0)