@@ -144,15 +144,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
144144 try await tester. checkBuild ( runDestination: destination, signableTargets: Set ( provisioningInputs. keys) , signableTargetInputs: provisioningInputs) { results in
145145 results. checkNoErrors ( )
146146
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) )
156148 #expect( executionResult. exitStatus == . exit( 0 ) )
157149 if core. hostOperatingSystem == . windows {
158150 #expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -377,15 +369,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
377369 }
378370 }
379371
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) )
389373 #expect( executionResult. exitStatus == . exit( 0 ) )
390374 if core. hostOperatingSystem == . windows {
391375 #expect( String ( decoding: executionResult. stdout, as: UTF8 . self) == " Hello world \r \n " )
@@ -480,13 +464,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
480464 try await tester. checkBuild ( runDestination: destination, persistent: true ) { results in
481465 results. checkNoErrors ( )
482466
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)
490468
491469 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)
492470 #expect( String ( decoding: executionResult. stderr, as: UTF8 . self) . contains ( " Test run started " ) )
0 commit comments