Skip to content

Commit aa882cf

Browse files
authored
Add rpath to test runner binaries to find adjacent test dylib (swiftlang#9218)
1 parent 8139158 commit aa882cf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,13 @@ extension PackagePIFProjectBuilder {
10121012
// This should eventually be set universally for all package targets/products.
10131013
settings[.LINKER_DRIVER] = "swiftc"
10141014

1015+
// A test-runner should always be adjacent to the dynamic library containing the tests,
1016+
// so add the appropriate rpaths.
1017+
settings[.LD_RUNPATH_SEARCH_PATHS] = [
1018+
"$(inherited)",
1019+
"$(RPATH_ORIGIN)"
1020+
]
1021+
10151022
let deploymentTargets = unitTestProduct.deploymentTargets
10161023
settings[.MACOSX_DEPLOYMENT_TARGET] = deploymentTargets?[.macOS] ?? nil
10171024
settings[.IPHONEOS_DEPLOYMENT_TARGET] = deploymentTargets?[.iOS] ?? nil

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,7 @@ struct TestCommandTests {
663663
}
664664
}
665665
} when: {
666-
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem)
667-
|| ProcessInfo.hostOperatingSystem == .windows
666+
ProcessInfo.hostOperatingSystem == .windows
668667
}
669668
}
670669

@@ -1011,7 +1010,7 @@ struct TestCommandTests {
10111010
)
10121011
}
10131012
} when: {
1014-
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem != .macOS
1013+
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows
10151014
}
10161015
}
10171016

0 commit comments

Comments
 (0)