From 916f13bd8e963d2b1fa488ebf2d4b0b9880dfc40 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Tue, 23 Jul 2024 16:03:06 -0700 Subject: [PATCH] Skip testSearchPaths_XDGEnvironmentVariables when XDG environment is set --- .../FileManager/FileManagerTests.swift | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift b/Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift index 1742af271..0558227fa 100644 --- a/Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift +++ b/Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift @@ -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")