Skip to content

Skip testSearchPaths_XDGEnvironmentVariables when XDG environment is set #761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2024
Merged
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
15 changes: 4 additions & 11 deletions Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -821,20 +821,13 @@ final class FileManagerTests : XCTestCase {
#if canImport(Darwin) || os(Windows)
throw XCTSkip("This test is not applicable on this platform")
#else
if let key = ProcessInfo.processInfo.environment.keys.first(where: { $0.starts(with: "XDG") }) {
throw XCTSkip("Skipping due to presence of '\(key)' environment variable which may affect this test")
}

try FileManagerPlayground {
Directory("TestPath") {}
}.test { fileManager in
#if os(Windows)
func setenv(_ key: String, _ value: String) -> Int32 {
assert(overwrite == 1)
guard !key.contains("=") else {
errno = EINVAL
return -1
}
return _putenv("\(key)=\(value)")
}
#endif

func validate(_ key: String, suffix: String? = nil, directory: FileManager.SearchPathDirectory, domain: FileManager.SearchPathDomainMask, file: StaticString = #filePath, line: UInt = #line) {
let oldValue = ProcessInfo.processInfo.environment[key] ?? ""
var knownPath = fileManager.currentDirectoryPath.appendingPathComponent("TestPath")
Expand Down