@@ -144,15 +144,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
144
144
try await tester. checkBuild ( runDestination: destination, signableTargets: Set ( provisioningInputs. keys) , signableTargetInputs: provisioningInputs) { results in
145
145
results. checkNoErrors ( )
146
146
147
- let toolchain = try #require( core. toolchainRegistry. defaultToolchain)
148
- let environment : Environment
149
- if destination. imageFormat ( core) == . elf {
150
- environment = [ " LD_LIBRARY_PATH " : toolchain. path. join ( " usr/lib/swift/ \( destination. platform) " ) . str]
151
- } else {
152
- environment = . init( )
153
- }
154
-
155
- 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)
147
+ 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) )
156
148
#expect( executionResult. exitStatus == . exit( 0 ) )
157
149
if core. hostOperatingSystem == . windows {
158
150
#expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -377,15 +369,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
377
369
}
378
370
}
379
371
380
- let toolchain = try #require( try await getCore ( ) . toolchainRegistry. defaultToolchain)
381
- let environment : Environment
382
- if destination. platform == " linux " {
383
- environment = [ " LD_LIBRARY_PATH " : toolchain. path. join ( " usr/lib/swift/linux " ) . str]
384
- } else {
385
- environment = . init( )
386
- }
387
-
388
- 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)
372
+ 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) )
389
373
#expect( executionResult. exitStatus == . exit( 0 ) )
390
374
if core. hostOperatingSystem == . windows {
391
375
#expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -480,13 +464,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
480
464
try await tester. checkBuild ( runDestination: destination, persistent: true ) { results in
481
465
results. checkNoErrors ( )
482
466
483
- let toolchain = try #require( try await getCore ( ) . toolchainRegistry. defaultToolchain)
484
- let environment : Environment
485
- if destination. platform == " linux " {
486
- environment = [ " LD_LIBRARY_PATH " : toolchain. path. join ( " usr/lib/swift/linux " ) . str]
487
- } else {
488
- environment = . init( )
489
- }
467
+ let environment = destination. hostRuntimeEnvironment ( core)
490
468
491
469
let executionResult = try await Process . getOutput ( url: URL ( fileURLWithPath: projectDir. join ( " build " ) . join ( " Debug \( destination. builtProductsDirSuffix) " ) . join ( core. hostOperatingSystem. imageFormat. executableName ( basename: " test.xctest " ) ) . str) , arguments: [ " --testing-library " , " swift-testing " ] , environment: environment)
492
470
#expect( String ( decoding: executionResult. stderr, as: UTF8 . self) . contains ( " Test run started " ) )
0 commit comments