@@ -145,15 +145,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
145
145
try await tester. checkBuild ( runDestination: destination, signableTargets: Set ( provisioningInputs. keys) , signableTargetInputs: provisioningInputs) { results in
146
146
results. checkNoErrors ( )
147
147
148
- let toolchain = try #require( core. toolchainRegistry. defaultToolchain)
149
- let environment : Environment
150
- if destination. imageFormat ( core) == . elf {
151
- environment = [ " LD_LIBRARY_PATH " : toolchain. path. join ( " usr/lib/swift/ \( destination. platform) " ) . str]
152
- } else {
153
- environment = . init( )
154
- }
155
-
156
- let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " tool " ) ) . str) , arguments: [ ] , environment: environment)
148
+ let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " tool " ) ) . str) , arguments: [ ] , environment: destination. hostRuntimeEnvironment ( core) )
157
149
#expect( executionResult. exitStatus == . exit( 0 ) )
158
150
if core. hostOperatingSystem == . windows {
159
151
#expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -378,15 +370,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
378
370
}
379
371
}
380
372
381
- let toolchain = try #require( try await getCore ( ) . toolchainRegistry. defaultToolchain)
382
- let environment : Environment
383
- if destination. platform == " linux " {
384
- environment = [ " LD_LIBRARY_PATH " : toolchain. path. join ( " usr/lib/swift/linux " ) . str]
385
- } else {
386
- environment = . init( )
387
- }
388
-
389
- let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " tool " ) ) . str) , arguments: [ ] , environment: environment)
373
+ let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " tool " ) ) . str) , arguments: [ ] , environment: destination. hostRuntimeEnvironment ( core) )
390
374
#expect( executionResult. exitStatus == . exit( 0 ) )
391
375
if core. hostOperatingSystem == . windows {
392
376
#expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -508,13 +492,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
508
492
try await tester. checkBuild ( runDestination: destination, persistent: true ) { results in
509
493
results. checkNoErrors ( )
510
494
511
- let toolchain = try #require( try await getCore ( ) . toolchainRegistry. defaultToolchain)
512
- let environment : Environment
513
- if destination. platform == " linux " {
514
- environment = [ " LD_LIBRARY_PATH " : " \( toolchain. path. join ( " usr/lib/swift/linux " ) . str) : \( projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) ) " ]
515
- } else {
516
- environment = . init( )
517
- }
495
+ let environment = destination. hostRuntimeEnvironment ( core)
518
496
519
497
do {
520
498
let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " UnitTestRunner " ) ) . str) , arguments: [ ] , environment: environment)
0 commit comments