Skip to content

Commit 42913b5

Browse files
authored
Skip testSearchPaths_XDGEnvironmentVariables when XDG environment is set (#761)
1 parent 196376b commit 42913b5

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -821,20 +821,13 @@ final class FileManagerTests : XCTestCase {
821821
#if canImport(Darwin) || os(Windows)
822822
throw XCTSkip("This test is not applicable on this platform")
823823
#else
824+
if let key = ProcessInfo.processInfo.environment.keys.first(where: { $0.starts(with: "XDG") }) {
825+
throw XCTSkip("Skipping due to presence of '\(key)' environment variable which may affect this test")
826+
}
827+
824828
try FileManagerPlayground {
825829
Directory("TestPath") {}
826830
}.test { fileManager in
827-
#if os(Windows)
828-
func setenv(_ key: String, _ value: String) -> Int32 {
829-
assert(overwrite == 1)
830-
guard !key.contains("=") else {
831-
errno = EINVAL
832-
return -1
833-
}
834-
return _putenv("\(key)=\(value)")
835-
}
836-
#endif
837-
838831
func validate(_ key: String, suffix: String? = nil, directory: FileManager.SearchPathDirectory, domain: FileManager.SearchPathDomainMask, file: StaticString = #filePath, line: UInt = #line) {
839832
let oldValue = ProcessInfo.processInfo.environment[key] ?? ""
840833
var knownPath = fileManager.currentDirectoryPath.appendingPathComponent("TestPath")

0 commit comments

Comments
 (0)