Skip to content

Commit 33a314b

Browse files
committed
Add diagnostic output to dependency scanning test.
To have more information for debugging when failing in one environment (e.g. CI) but not other.
1 parent c4a3aa5 commit 33a314b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,15 @@ final class ExplicitModuleBuildTests: XCTestCase {
519519
.parentDirectory // toolchain root
520520
let stdLibPath = toolchainRootPath.appending(component: "lib")
521521
.appending(component: "swift")
522-
.appending(component: "macosx")
522+
.appending(component: driver.targetTriple.osNameUnversioned)
523523
let shimsPath = toolchainRootPath.appending(component: "lib")
524524
.appending(component: "swift")
525525
.appending(component: "shims")
526+
XCTAssertTrue(localFileSystem.exists(stdLibPath),
527+
"expected Swift StdLib at: \(stdLibPath.description)")
528+
XCTAssertTrue(localFileSystem.exists(shimsPath),
529+
"expected Swift Shims at: \(shimsPath.description)")
530+
526531
// The dependency oracle wraps an instance of libSwiftScan and ensures thread safety across
527532
// queries.
528533
let dependencyOracle = InterModuleDependencyOracle()
@@ -551,6 +556,9 @@ final class ExplicitModuleBuildTests: XCTestCase {
551556
"-I", shimsPath.description,
552557
main.pathString]
553558

559+
// Here purely to dump diagnostic output in a reasonable fashion when things go wrong.
560+
let lock = NSLock()
561+
554562
// Dispatch several iterations in parallel
555563
DispatchQueue.concurrentPerform(iterations: 20) { index in
556564
// Give the main modules different names
@@ -559,6 +567,14 @@ final class ExplicitModuleBuildTests: XCTestCase {
559567
let dependencyGraph =
560568
try! dependencyOracle.getDependencies(workingDirectory: path,
561569
commandLine: iterationCommand)
570+
if (dependencyGraph.modules.count != 11) {
571+
lock.lock()
572+
print("Unexpected Dependency Scanning Result (\(dependencyGraph.modules.count) modules):")
573+
dependencyGraph.modules.forEach {
574+
print($0.key.moduleName)
575+
}
576+
lock.unlock()
577+
}
562578
XCTAssertTrue(dependencyGraph.modules.count == 11)
563579
}
564580
}

0 commit comments

Comments
 (0)