@@ -108,7 +108,7 @@ enum TestingSupport {
108
108
#if os(macOS)
109
109
let data : String = try withTemporaryFile { tempFile in
110
110
args = [ try Self . xctestHelperPath ( swiftTool: swiftTool) . pathString, path. pathString, tempFile. path. pathString]
111
- let env = try Self . constructTestEnvironment (
111
+ var env = try Self . constructTestEnvironment (
112
112
toolchain: try swiftTool. getTargetToolchain ( ) ,
113
113
buildParameters: swiftTool. buildParametersForTest (
114
114
enableCodeCoverage: enableCodeCoverage,
@@ -118,6 +118,12 @@ enum TestingSupport {
118
118
sanitizers: sanitizers
119
119
)
120
120
121
+ // Add the sdk platform path if we have it. If this is not present, we might always end up failing.
122
+ let sdkPlatformFrameworksPath = try SwiftSDK . sdkPlatformFrameworkPaths ( )
123
+ // appending since we prefer the user setting (if set) to the one we inject
124
+ env. appendPath ( " DYLD_FRAMEWORK_PATH " , value: sdkPlatformFrameworksPath. fwk. pathString)
125
+ env. appendPath ( " DYLD_LIBRARY_PATH " , value: sdkPlatformFrameworksPath. lib. pathString)
126
+
121
127
try TSCBasic . Process. checkNonZeroExit ( arguments: args, environment: env)
122
128
// Read the temporary file's content.
123
129
return try swiftTool. fileSystem. readFileContents ( AbsolutePath ( tempFile. path) )
@@ -174,12 +180,6 @@ enum TestingSupport {
174
180
#endif
175
181
return env
176
182
#else
177
- // Add the sdk platform path if we have it. If this is not present, we might always end up failing.
178
- let sdkPlatformFrameworksPath = try SwiftSDK . sdkPlatformFrameworkPaths ( )
179
- // appending since we prefer the user setting (if set) to the one we inject
180
- env. appendPath ( " DYLD_FRAMEWORK_PATH " , value: sdkPlatformFrameworksPath. fwk. pathString)
181
- env. appendPath ( " DYLD_LIBRARY_PATH " , value: sdkPlatformFrameworksPath. lib. pathString)
182
-
183
183
// Fast path when no sanitizers are enabled.
184
184
if sanitizers. isEmpty {
185
185
return env
0 commit comments