Skip to content

Commit 03c10be

Browse files
authored
Avoid searching for xctest with non-Darwin triples (#2731)
1 parent 0d8e8d9 commit 03c10be

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Sources/Workspace/UserToolchain.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,20 @@ public final class UserToolchain: Toolchain {
244244

245245
let swiftCompilers = try UserToolchain.determineSwiftCompilers(binDir: binDir, lookup: { UserToolchain.lookup(variable: $0, searchPaths: searchPaths) }, envSearchPaths: searchPaths)
246246
self.swiftCompiler = swiftCompilers.compile
247-
248-
// We require xctest to exist on macOS.
249-
#if os(macOS)
250-
// FIXME: We should have some general utility to find tools.
251-
let xctestFindArgs = ["/usr/bin/xcrun", "--sdk", "macosx", "--find", "xctest"]
252-
self.xctest = try AbsolutePath(validating: Process.checkNonZeroExit(arguments: xctestFindArgs, environment: environment).spm_chomp())
253-
#else
254-
self.xctest = nil
255-
#endif
256-
247+
257248
// Use the triple from destination or compute the host triple using swiftc.
258249
let triple = destination.target ?? Triple.getHostTriple(usingSwiftCompiler: swiftCompilers.compile)
259250
self.triple = triple
251+
252+
// We require xctest to exist on macOS.
253+
if triple.isDarwin() {
254+
// FIXME: We should have some general utility to find tools.
255+
let xctestFindArgs = ["/usr/bin/xcrun", "--sdk", "macosx", "--find", "xctest"]
256+
self.xctest = try AbsolutePath(validating: Process.checkNonZeroExit(arguments: xctestFindArgs, environment: environment).spm_chomp())
257+
} else {
258+
self.xctest = nil
259+
}
260+
260261
self.extraSwiftCFlags = UserToolchain.deriveSwiftCFlags(triple: triple, destination: destination)
261262

262263
self.extraCCFlags = [

0 commit comments

Comments
 (0)