@@ -537,6 +537,74 @@ extension IncrementalCompilationTests {
537
537
}
538
538
}
539
539
540
+ // MARK: - Incremental argument hashing tests
541
+ extension IncrementalCompilationTests {
542
+ func testNullBuildWhenAddingAndRemovingArgumentsNotAffectingIncrementalBuilds( ) throws {
543
+ // Adding, removing, or changing the arguments of options which don't affect incremental builds should result in a null build.
544
+ try buildInitialState ( extraArguments: [ " -driver-batch-size-limit " , " 5 " , " -debug-diagnostic-names " ] )
545
+ let driver = try checkNullBuild ( extraArguments: [ " -driver-batch-size-limit " , " 10 " , " -diagnostic-style " , " swift " ] )
546
+ let mandatoryJobs = try XCTUnwrap ( driver. incrementalCompilationState? . mandatoryJobsInOrder)
547
+ XCTAssertTrue ( mandatoryJobs. isEmpty)
548
+ }
549
+
550
+ func testChangingOptionArgumentLeadsToRecompile( ) throws {
551
+ // If an option affects incremental builds, changing only the argument should trigger a full recompile.
552
+ try buildInitialState ( extraArguments: [ " -user-module-version " , " 1.0 " ] )
553
+ try doABuild (
554
+ " change user module version " ,
555
+ checkDiagnostics: true ,
556
+ extraArguments: [ " -user-module-version " , " 1.1 " ] ,
557
+ whenAutolinking: autolinkLifecycleExpectedDiags
558
+ ) {
559
+ enablingCrossModule
560
+ differentArgsPassed
561
+ disablingIncrementalDifferentArgsPassed
562
+ createdGraphFromSwiftdeps
563
+ findingBatchingCompiling ( " main " , " other " )
564
+ reading ( deps: " main " , " other " )
565
+ schedLinking
566
+ }
567
+ }
568
+
569
+ func testOptionReorderingLeadsToRecompile( ) throws {
570
+ // Reordering options which affect incremental builds should trigger a full recompile.
571
+ try buildInitialState ( extraArguments: [ " -warnings-as-errors " , " -no-warnings-as-errors " ] )
572
+ try doABuild (
573
+ " change user module version " ,
574
+ checkDiagnostics: true ,
575
+ extraArguments: [ " -no-warnings-as-errors " , " -warnings-as-errors " ] ,
576
+ whenAutolinking: autolinkLifecycleExpectedDiags
577
+ ) {
578
+ enablingCrossModule
579
+ differentArgsPassed
580
+ disablingIncrementalDifferentArgsPassed
581
+ createdGraphFromSwiftdeps
582
+ findingBatchingCompiling ( " main " , " other " )
583
+ reading ( deps: " main " , " other " )
584
+ schedLinking
585
+ }
586
+ }
587
+
588
+ func testArgumentReorderingLeadsToRecompile( ) throws {
589
+ // Reordering the arguments of an option which affect incremental builds should trigger a full recompile.
590
+ try buildInitialState ( extraArguments: [ " -Ifoo " , " -Ibar " ] )
591
+ try doABuild (
592
+ " change user module version " ,
593
+ checkDiagnostics: true ,
594
+ extraArguments: [ " -Ibar " , " -Ifoo " ] ,
595
+ whenAutolinking: autolinkLifecycleExpectedDiags
596
+ ) {
597
+ enablingCrossModule
598
+ differentArgsPassed
599
+ disablingIncrementalDifferentArgsPassed
600
+ createdGraphFromSwiftdeps
601
+ findingBatchingCompiling ( " main " , " other " )
602
+ reading ( deps: " main " , " other " )
603
+ schedLinking
604
+ }
605
+ }
606
+ }
607
+
540
608
// MARK: - Incremental test stages
541
609
extension IncrementalCompilationTests {
542
610
/// Setup the initial post-build state.
@@ -1390,6 +1458,12 @@ extension DiagVerifiable {
1390
1458
@DiagsBuilder var disablingIncrementalCannotReadBuildRecord : [ Diagnostic . Message ] {
1391
1459
" Incremental compilation: Disabling incremental build: could not read build record "
1392
1460
}
1461
+ @DiagsBuilder var differentArgsPassed : [ Diagnostic . Message ] {
1462
+ " Incremental compilation: Incremental compilation has been disabled, because different arguments were passed to the compiler "
1463
+ }
1464
+ @DiagsBuilder var disablingIncrementalDifferentArgsPassed : [ Diagnostic . Message ] {
1465
+ " Incremental compilation: Disabling incremental build: different arguments were passed to the compiler "
1466
+ }
1393
1467
@DiagsBuilder var missingMainDependencyEntry : [ Diagnostic . Message ] {
1394
1468
. warning( " ignoring -incremental; output file map has no master dependencies entry ( \" swift-dependencies \" under \" \" ) " )
1395
1469
}
0 commit comments