@@ -516,6 +516,56 @@ extension IncrementalCompilationTests {
516
516
linking
517
517
}
518
518
}
519
+
520
+ func testExplicitIncrementalBuildUnchangedBinaryDependencyDoesNotInvalidateUpstreamDependencies( ) throws {
521
+ replace ( contentsOf: " other " , with: " import J; " )
522
+
523
+ // After an initial build, replace the G.swiftinterface with G.swiftmodule
524
+ // and repeat the initial build to settle into the "initial" state for the test
525
+ try buildInitialState ( checkDiagnostics: false , explicitModuleBuild: true )
526
+ let modCacheEntries = try localFileSystem. getDirectoryContents ( explicitModuleCacheDir)
527
+ let nameOfGModule = try XCTUnwrap ( modCacheEntries. first { $0. hasPrefix ( " G " ) && $0. hasSuffix ( " .swiftmodule " ) } )
528
+ let pathToGModule = explicitModuleCacheDir. appending ( component: nameOfGModule)
529
+ // Rename the binary module to G.swiftmodule so that the next build's scan finds it.
530
+ let newPathToGModule = explicitSwiftDependenciesPath. appending ( component: " G.swiftmodule " )
531
+ try ! localFileSystem. move ( from: pathToGModule, to: newPathToGModule)
532
+ // Delete the textual interface it was built from so that it is treated as a binary-only dependency now.
533
+ try ! localFileSystem. removeFileTree ( try AbsolutePath ( validating: explicitSwiftDependenciesPath. appending ( component: " G.swiftinterface " ) . pathString) )
534
+ try buildInitialState ( checkDiagnostics: false , explicitModuleBuild: true )
535
+
536
+ // Touch one of the inputs to actually trigger the incremental build, so that we can ensure
537
+ // no module deps get re-built
538
+ touch ( inputPath ( basename: " other " ) )
539
+
540
+ try doABuild (
541
+ " Unchanged binary dependency (G) " ,
542
+ checkDiagnostics: true ,
543
+ extraArguments: explicitBuildArgs,
544
+ whenAutolinking: autolinkLifecycleExpectedDiags
545
+ ) {
546
+ readGraph
547
+ enablingCrossModule
548
+ noFingerprintInSwiftModule ( " G.swiftinterface " )
549
+ dependencyNewerThanNode ( " G.swiftinterface " )
550
+ dependencyNewerThanNode ( " G.swiftinterface " ) // FIXME: Why do we see this twice?
551
+ readInterModuleGraph
552
+ interModuleDependencyGraphUpToDate // Graph declared up-to-date despite a downstream dependency on a binary Swift module dependency
553
+ maySkip ( " main " )
554
+ schedulingChangedInitialQueuing ( " other " )
555
+ fingerprintsMissingOfTopLevelName ( name: " foo " , " main " )
556
+ invalidatedExternally ( " main " , " other " )
557
+ queuingInitial ( " main " )
558
+ foundBatchableJobs ( 2 )
559
+ formingOneBatch
560
+ addingToBatchThenForming ( " main " , " other " )
561
+ compiling ( " main " , " other " )
562
+ reading ( deps: " main " )
563
+ reading ( deps: " other " )
564
+ schedulingPostCompileJobs
565
+ linking
566
+
567
+ }
568
+ }
519
569
}
520
570
521
571
extension IncrementalCompilationTests {
0 commit comments