@@ -280,6 +280,22 @@ extension IncrementalCompilationTests {
280
280
try checkNullBuild ( checkDiagnostics: true )
281
281
}
282
282
}
283
+
284
+ func testSymlinkModification( ) throws {
285
+ // Remap
286
+ // main.swift -> main.swift~link-target.swift
287
+ // other.swift -> other.swift~link-target.swift
288
+ for (file, _) in self . inputPathsAndContents {
289
+ try localFileSystem. createDirectory ( tempDir. appending ( component: " links " ) )
290
+ let linkTarget = tempDir. appending ( component: " links " ) . appending ( component: file. basename)
291
+ try localFileSystem. move ( from: file, to: linkTarget)
292
+ try localFileSystem. removeFileTree ( file)
293
+ try localFileSystem. createSymbolicLink ( file, pointingAt: linkTarget, relative: false )
294
+ }
295
+ try buildInitialState ( )
296
+ try checkReactionToTouchingSymlinks ( )
297
+ try checkReactionToTouchingSymlinkTargets ( )
298
+ }
283
299
}
284
300
285
301
// MARK: - Test adding an input
@@ -622,6 +638,69 @@ extension IncrementalCompilationTests {
622
638
XCTAssert ( graph. contains ( sourceBasenameWithoutExt: newInput) )
623
639
XCTAssert ( graph. contains ( name: topLevelName) )
624
640
}
641
+
642
+ /// Check reaction to touching all symlinks
643
+ private func checkReactionToTouchingSymlinks(
644
+ checkDiagnostics: Bool = false ,
645
+ extraArguments: [ String ] = [ ]
646
+ ) throws {
647
+ for (file, _) in self . inputPathsAndContents {
648
+ try localFileSystem. removeFileTree ( file)
649
+ let linkTarget = tempDir. appending ( component: " links " ) . appending ( component: file. basename)
650
+ try localFileSystem. createSymbolicLink ( file, pointingAt: linkTarget, relative: false )
651
+ }
652
+ try doABuild (
653
+ " touch both symlinks; non-propagating " ,
654
+ checkDiagnostics: checkDiagnostics,
655
+ extraArguments: extraArguments,
656
+ expectingRemarks: [
657
+ " Enabling incremental cross-module building " ,
658
+ " Incremental compilation: Read dependency graph " ,
659
+ " Incremental compilation: May skip current input {compile: main.o <= main.swift} " ,
660
+ " Incremental compilation: May skip current input {compile: other.o <= other.swift} " ,
661
+ " Incremental compilation: Skipping input: {compile: main.o <= main.swift} " ,
662
+ " Incremental compilation: Skipping input: {compile: other.o <= other.swift} " ,
663
+ " Incremental compilation: Skipping job: Linking theModule " ,
664
+ " Skipped Compiling main.swift " ,
665
+ " Skipped Compiling other.swift " ,
666
+ ] ,
667
+ whenAutolinking: autolinkLifecycleExpectations)
668
+ }
669
+
670
+ private func checkReactionToTouchingSymlinkTargets(
671
+ checkDiagnostics: Bool = false ,
672
+ extraArguments: [ String ] = [ ]
673
+ ) throws {
674
+ for (file, contents) in self . inputPathsAndContents {
675
+ let linkTarget = tempDir. appending ( component: " links " ) . appending ( component: file. basename)
676
+ try ! localFileSystem. writeFileContents ( linkTarget) { $0 <<< contents }
677
+ }
678
+ try doABuild (
679
+ " touch both symlink targets; non-propagating " ,
680
+ checkDiagnostics: checkDiagnostics,
681
+ extraArguments: extraArguments,
682
+ expectingRemarks: [
683
+ " Enabling incremental cross-module building " ,
684
+ " Incremental compilation: Read dependency graph " ,
685
+ " Incremental compilation: Scheduing changed input {compile: main.o <= main.swift} " ,
686
+ " Incremental compilation: Scheduing changed input {compile: other.o <= other.swift} " ,
687
+ " Incremental compilation: Queuing (initial): {compile: main.o <= main.swift} " ,
688
+ " Incremental compilation: Queuing (initial): {compile: other.o <= other.swift} " ,
689
+ " Incremental compilation: not scheduling dependents of main.swift; unknown changes " ,
690
+ " Incremental compilation: not scheduling dependents of other.swift; unknown changes " ,
691
+ " Found 2 batchable jobs " ,
692
+ " Forming into 1 batch " ,
693
+ " Adding {compile: main.swift} to batch 0 " ,
694
+ " Adding {compile: other.swift} to batch 0 " ,
695
+ " Forming batch job from 2 constituents: main.swift, other.swift " ,
696
+ " Starting Compiling main.swift, other.swift " ,
697
+ " Finished Compiling main.swift, other.swift " ,
698
+ " Incremental compilation: Scheduling all post-compile jobs because something was compiled " ,
699
+ " Starting Linking theModule " ,
700
+ " Finished Linking theModule " ,
701
+ ] ,
702
+ whenAutolinking: autolinkLifecycleExpectations)
703
+ }
625
704
}
626
705
627
706
// MARK: - Incremental test perturbation helpers
@@ -776,8 +855,7 @@ extension IncrementalCompilationTests {
776
855
}
777
856
}
778
857
779
- private func doABuildWithoutExpectations( arguments: [ String ]
780
- ) throws -> Driver {
858
+ private func doABuildWithoutExpectations( arguments: [ String ] ) throws -> Driver {
781
859
// If not checking, print out the diagnostics
782
860
let diagnosticEngine = DiagnosticsEngine ( handlers: [
783
861
{ print ( $0, to: & stderrStream) ; stderrStream. flush ( ) }
0 commit comments