@@ -362,6 +362,14 @@ final class IncrementalCompilationTests: XCTestCase {
362362 #endif
363363 }
364364
365+ // FIXME: Expect failure in Linux in CI just as testIncrementalDiagnostics
366+ func testAlwaysRebuildDependents( ) throws {
367+ #if !os(Linux)
368+ tryInitial ( true )
369+ tryTouchingMainAlwaysRebuildDependents ( true )
370+ #endif
371+ }
372+
365373 func testIncremental( ) throws {
366374 try testIncremental ( checkDiagnostics: false )
367375 }
@@ -499,6 +507,36 @@ final class IncrementalCompilationTests: XCTestCase {
499507 ] ,
500508 whenAutolinking: autolinkLifecycleExpectations)
501509 }
510+ func tryTouchingMainAlwaysRebuildDependents( _ checkDiagnostics: Bool ) {
511+ touch ( " main " )
512+ let extraArgument = " -driver-always-rebuild-dependents "
513+ try ! doABuild (
514+ " non-propagating but \( extraArgument) " ,
515+ checkDiagnostics: checkDiagnostics,
516+ extraArguments: [ extraArgument] ,
517+ expectingRemarks: [
518+ " Incremental compilation: Scheduing changed input {compile: main.o <= main.swift} " ,
519+ " Incremental compilation: May skip current input: {compile: other.o <= other.swift} " ,
520+ " Incremental compilation: Queuing (initial): {compile: main.o <= main.swift} " ,
521+ " Incremental compilation: scheduling dependents of main.swift; -driver-always-rebuild-dependents " ,
522+ " Incremental compilation: Traced: interface of top-level name foo from: main.swift -> implementation of other.swiftdeps from: other.swift " ,
523+ " Incremental compilation: Found dependent of main.swift: {compile: other.o <= other.swift} " ,
524+ " Incremental compilation: Immediately scheduling dependent on main.swift {compile: other.o <= other.swift} " ,
525+ " Incremental compilation: Queuing (dependent): {compile: other.o <= other.swift} " ,
526+ " Found 2 batchable jobs " ,
527+ " Forming into 1 batch " ,
528+ " Adding {compile: main.swift} to batch 0 " ,
529+ " Adding {compile: other.swift} to batch 0 " ,
530+ " Forming batch job from 2 constituents: main.swift, other.swift " ,
531+ " Incremental compilation: Queuing Compiling main.swift, other.swift " ,
532+ " Starting Compiling main.swift, other.swift " ,
533+ " Finished Compiling main.swift, other.swift " ,
534+ " Starting Linking theModule " ,
535+ " Finished Linking theModule " ,
536+ ] ,
537+ whenAutolinking: autolinkLifecycleExpectations)
538+ }
539+
502540
503541 func touch( _ name: String ) {
504542 print ( " *** touching \( name) *** " , to: & stderrStream) ; stderrStream. flush ( )
@@ -517,17 +555,20 @@ final class IncrementalCompilationTests: XCTestCase {
517555 }
518556 func doABuild( _ message: String ,
519557 checkDiagnostics: Bool ,
558+ extraArguments: [ String ] = [ ] ,
520559 expectingRemarks texts: [ String ] ,
521560 whenAutolinking: [ String ] ) throws {
522561 try doABuild (
523562 message,
524563 checkDiagnostics: checkDiagnostics,
564+ extraArguments: extraArguments,
525565 expecting: texts. map { . remark( $0) } ,
526566 expectingWhenAutolinking: whenAutolinking. map { . remark( $0) } )
527567 }
528568
529569 func doABuild( _ message: String ,
530570 checkDiagnostics: Bool ,
571+ extraArguments: [ String ] = [ ] ,
531572 expecting expectations: [ Diagnostic . Message ] ,
532573 expectingWhenAutolinking autolinkExpectations: [ Diagnostic . Message ] ) throws {
533574 print ( " *** starting build \( message) *** " , to: & stderrStream) ; stderrStream. flush ( )
@@ -537,8 +578,9 @@ final class IncrementalCompilationTests: XCTestCase {
537578 try ? driver. run ( jobs: jobs)
538579 }
539580
581+ let allArgs = args + extraArguments
540582 if checkDiagnostics {
541- try assertDriverDiagnostics ( args: args ) { driver, verifier in
583+ try assertDriverDiagnostics ( args: allArgs ) { driver, verifier in
542584 verifier. forbidUnexpected ( . error, . warning, . note, . remark, . ignored)
543585 expectations. forEach { verifier. expect ( $0) }
544586 if driver. isAutolinkExtractJobNeeded {
@@ -551,7 +593,7 @@ final class IncrementalCompilationTests: XCTestCase {
551593 let diagnosticEngine = DiagnosticsEngine ( handlers: [
552594 { print ( $0, to: & stderrStream) ; stderrStream. flush ( ) }
553595 ] )
554- var driver = try Driver ( args: args , env: ProcessEnv . vars,
596+ var driver = try Driver ( args: allArgs , env: ProcessEnv . vars,
555597 diagnosticsEngine: diagnosticEngine,
556598 fileSystem: localFileSystem)
557599 doIt ( & driver)
0 commit comments