File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -886,13 +886,8 @@ final class TestRunner {
886
886
}
887
887
args += [ xctestPath. pathString]
888
888
case . swiftTesting:
889
- // FIXME: better way to get path to self
890
- let toolPath = String ( unsafeUninitializedCapacity: 2048 ) { buffer in
891
- var count = UInt32 ( buffer. count)
892
- _NSGetExecutablePath ( buffer. baseAddress!, & count)
893
- return Int ( count)
894
- }
895
- args += [ toolPath, " --test-bundle-path " , testPath. pathString]
889
+ let helper = try self . toolchain. getSwiftTestingHelper ( )
890
+ args += [ helper. pathString, " --test-bundle-path " , testPath. pathString]
896
891
}
897
892
args += additionalArguments
898
893
args += [ testPath. pathString]
Original file line number Diff line number Diff line change @@ -387,6 +387,24 @@ public final class UserToolchain: Toolchain {
387
387
)
388
388
}
389
389
390
+ #if os(macOS)
391
+ public func getSwiftTestingHelper( ) throws -> AbsolutePath {
392
+ // The helper would be located in `.build/<config>` directory when
393
+ // SwiftPM is built locally and `usr/libexec/swift/pm` directory in
394
+ // an installed version.
395
+ let binDirectories = self . swiftSDK. toolset. rootPaths +
396
+ self . swiftSDK. toolset. rootPaths. map {
397
+ $0. parentDirectory. appending ( components: [ " libexec " , " swift " , " pm " ] )
398
+ }
399
+
400
+ return try UserToolchain . getTool (
401
+ " swiftpm-testing-helper " ,
402
+ binDirectories: binDirectories,
403
+ fileSystem: self . fileSystem
404
+ )
405
+ }
406
+ #endif
407
+
390
408
internal static func deriveSwiftCFlags(
391
409
triple: Triple ,
392
410
swiftSDK: SwiftSDK ,
You can’t perform that action at this time.
0 commit comments