Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Tests/Foundation/TestFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ class TestFileManager : XCTestCase {

func test_homedirectoryForUser() {
let filemanger = FileManager.default
XCTAssertNotNil(filemanger.homeDirectory(forUser: "someuser"))
XCTAssertNotNil(filemanger.homeDirectory(forUser: ""))
XCTAssertNil(filemanger.homeDirectory(forUser: "someuser"))
XCTAssertNil(filemanger.homeDirectory(forUser: ""))
XCTAssertNotNil(filemanger.homeDirectoryForCurrentUser)
}

Expand Down Expand Up @@ -1268,15 +1268,13 @@ class TestFileManager : XCTestCase {
let fm = FileManager.default

#if os(Windows)
let defaultHomeDirectory = ProcessInfo.processInfo.environment["ALLUSERSPROFILE"]!
let emptyFileNameError: CocoaError.Code? = .fileReadInvalidFileName
#else
let defaultHomeDirectory = "/var/empty"
let emptyFileNameError: CocoaError.Code? = nil
#endif

XCTAssertEqual(fm.homeDirectory(forUser: ""), URL(filePath: defaultHomeDirectory, directoryHint: .isDirectory))
XCTAssertEqual(NSHomeDirectoryForUser(""), defaultHomeDirectory)
XCTAssertNil(fm.homeDirectory(forUser: ""))
XCTAssertNil(NSHomeDirectoryForUser(""))

XCTAssertThrowsError(try fm.contentsOfDirectory(atPath: "")) {
let code = ($0 as? CocoaError)?.code
Expand Down
6 changes: 1 addition & 5 deletions Tests/Foundation/TestNSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,7 @@ class TestNSString: LoopbackServerTest {
let path = NSString(string: "~\(userName)/")
let result = path.expandingTildeInPath
// next assert fails in VirtualBox because home directory for unknown user resolved to /var/run/vboxadd
#if os(Windows)
XCTAssertEqual(result, ProcessInfo.processInfo.environment["ALLUSERSPROFILE"])
#else
XCTAssertEqual(result, "/var/empty", "Return copy of receiver if home directory could not be resolved.")
#endif
XCTAssertEqual(result, "~\(userName)", "Return copy of receiver if home directory could not be resolved.")
}
}

Expand Down