Skip to content

Commit 37b8b44

Browse files
committed
Pass through LD_*/DYLD_* environment variables.
1 parent cf348b8 commit 37b8b44

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

TestFoundation/TestFileManager.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,17 @@ VIDEOS=StopgapVideos
10961096
try? FileManager.default.removeItem(at: path)
10971097
}
10981098

1099+
var environment = [ "XDG_CONFIG_HOME": path.path,
1100+
"_NSFileManagerUseXDGPathsForDirectoryDomains": "YES" ]
1101+
1102+
// Copy all LD_* and DYLD_* variables over, in case we're running with altered paths (e.g. from ninja test on Linux)
1103+
for entry in ProcessInfo.processInfo.environment.lazy.filter({ $0.key.hasPrefix("DYLD_") || $0.key.hasPrefix("LD_") }) {
1104+
environment[entry.key] = entry.value
1105+
}
1106+
10991107
let helper = xdgTestHelperURL()
11001108
let (stdout, _) = try runTask([ helper.path, "--nspathfor", method, identifier ],
1101-
environment: [ "XDG_CONFIG_HOME": path.path,
1102-
"_NSFileManagerUseXDGPathsForDirectoryDomains": "YES" ])
1109+
environment: environment)
11031110

11041111
return stdout.trimmingCharacters(in: CharacterSet.newlines)
11051112
}

0 commit comments

Comments
 (0)