Skip to content

Commit f9ea14a

Browse files
Copilotchsienki
andcommitted
Fix test expectations for incremental framework
Co-authored-by: chsienki <16246502+chsienki@users.noreply.github.com>
1 parent 367abe1 commit f9ea14a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,9 @@ public class Person
632632
Assert.Empty(result.Diagnostics);
633633
Assert.Equal(2, result.GeneratedSources.Length);
634634

635-
// When a C# type changes, only TagHelpersFromCompilation should re-run
636-
result.VerifyIncrementalSteps("TagHelpersFromCompilation", IncrementalStepRunReason.Modified);
635+
// When a C# type changes, TagHelpersFromCompilation re-runs but the output is unchanged
636+
// because Person is not a component and doesn't affect tag helpers
637+
result.VerifyIncrementalSteps("TagHelpersFromCompilation", IncrementalStepRunReason.Unchanged);
637638
}
638639

639640
[Fact]
@@ -3334,7 +3335,7 @@ public async Task RazorClassLibrary_Change_Updates_DependentProject_WhenReferenc
33343335
mainProject = mainProject.AddMetadataReference(rclReference);
33353336

33363337
var mainCompilation = await mainProject.GetCompilationAsync();
3337-
var (mainDriver, mainAdditionalTexts) = await GetDriverWithAdditionalTextAsync(mainProject);
3338+
var (mainDriver, mainAdditionalTexts, _) = await GetDriverWithAdditionalTextAndProviderAsync(mainProject, trackSteps: true);
33383339
var mainRun = RunGenerator(mainCompilation!, ref mainDriver);
33393340
Assert.Empty(mainRun.Diagnostics);
33403341
Assert.Single(mainRun.GeneratedSources);
@@ -3374,19 +3375,15 @@ public async Task RazorClassLibrary_Change_Updates_DependentProject_WhenReferenc
33743375
Assert.Empty(mainRun.Diagnostics);
33753376
Assert.Single(mainRun.GeneratedSources);
33763377

3377-
// Update the compilation, which will cause us to re-run with tracking enabled
3378-
var (mainDriverWithTracking, _, _) = await GetDriverWithAdditionalTextAndProviderAsync(mainProject, trackSteps: true);
3379-
mainDriverWithTracking = mainDriverWithTracking.ReplaceAdditionalText(
3380-
mainAdditionalTexts.First(t => t.Path.EndsWith("Index.razor", StringComparison.OrdinalIgnoreCase)),
3381-
updatedIndex);
3382-
3378+
// Update the compilation, which will cause us to re-run
33833379
mainCompilation = mainCompilation!.WithOptions(mainCompilation.Options.WithModuleName("newMain"));
3384-
mainRun = RunGenerator(mainCompilation!, ref mainDriverWithTracking);
3380+
mainRun = RunGenerator(mainCompilation!, ref mainDriver);
33853381
Assert.Empty(mainRun.Diagnostics);
33863382
Assert.Single(mainRun.GeneratedSources);
33873383

33883384
// Confirm that the tag helpers from metadata refs _didn't_ re-run
3389-
mainRun.VerifyIncrementalSteps("TagHelpersFromCompilation", IncrementalStepRunReason.Modified);
3385+
// TagHelpersFromCompilation re-runs when compilation changes but output is unchanged
3386+
mainRun.VerifyIncrementalSteps("TagHelpersFromCompilation", IncrementalStepRunReason.Unchanged);
33903387
}
33913388
}
33923389
}

0 commit comments

Comments
 (0)