Skip to content

Commit c054c52

Browse files
committed
test: correct test assumption for Windows paths
The Windows file system path representation `\` is a drive letter relative path. That is, the same path can be used across multiple drives (similar to the concept of alternate roots). We expect that the path returned is `[[:letter:]]:` or `[[:letter:]]:[\\/]` rather than the Unix `/`. Adjust the expectation.
1 parent f80087a commit c054c52

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Tests/Foundation/Tests/TestProcess.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,16 @@ class TestProcess : XCTestCase {
634634

635635
do {
636636
let (stdout, _) = try runTask([xdgTestHelperURL().path, "--getcwd"], currentDirectoryPath: "/")
637-
XCTAssertEqual(stdout.trimmingCharacters(in: CharacterSet(["\n", "\r"])), "/")
637+
var directory = stdout.trimmingCharacters(in: CharacterSet(["\n", "\r"]))
638+
#if os(Windows)
639+
let zero: String.Index = directory.startIndex
640+
let one: String.Index = directory.index(zero, offsetBy: 1)
641+
XCTAssertTrue(directory[zero].isLetter)
642+
XCTAssertEqual(directory[one], ":")
643+
directory = "/" + String(directory.dropFirst(2))
644+
#endif
645+
XCTAssertEqual(URL(fileURLWithPath: directory).absoluteURL,
646+
URL(fileURLWithPath: "/").absoluteURL)
638647
}
639648

640649
do {

0 commit comments

Comments
 (0)