diff --git a/Packages/src/Editor/CliOnlyTools~/CompileCheck/Skill/SKILL.md b/Packages/src/Editor/CliOnlyTools~/CompileCheck/Skill/SKILL.md index aac289225..6e73277ee 100644 --- a/Packages/src/Editor/CliOnlyTools~/CompileCheck/Skill/SKILL.md +++ b/Packages/src/Editor/CliOnlyTools~/CompileCheck/Skill/SKILL.md @@ -59,10 +59,10 @@ directive counts as a declaration change. Such a check skips a few assembly-wide with `--full` before finishing. When the project treats warnings as errors, a rule listed in `UncheckedCodes`, such as CS0414, can fail that `--full` run only. The first body edit after a Unity build, after a full compile that had errors (a `--full` run or a run that fell back to one), after -a run that compiled it only because an assembly it references changed, after a run that skipped the -assembly, or after `--all` in an assembly that references one whose rebuilt API differed from the -last Unity build and that the next run no longer rebuilds is compiled in full and records what the -next check compares against; `FastPathFallbacks` says why. +a run that picked it up only because an assembly it references changed, whether it compiled or +skipped the assembly, or after `--all` in an assembly that references one whose rebuilt API +differed from the last Unity build and that the next run no longer rebuilds is compiled in full and +records what the next check compares against; `FastPathFallbacks` says why. ## Parameters diff --git a/cli/dispatcher/internal/compilecheck/fast_path_test.go b/cli/dispatcher/internal/compilecheck/fast_path_test.go index b4bdd277d..1f43e6a81 100644 --- a/cli/dispatcher/internal/compilecheck/fast_path_test.go +++ b/cli/dispatcher/internal/compilecheck/fast_path_test.go @@ -470,6 +470,29 @@ func TestRevertedContentIsReused(t *testing.T) { } } +// Verifies that a run leaving an assembly out of its plan, because nothing it compiles from changed, +// keeps that assembly's outputs, result, and baseline as they were, whether the run compiles nothing +// or only another assembly, so the next body edit of it is checked against that baseline. +func TestRunLeavingAnAssemblyOutKeepsItsBaseline(t *testing.T) { + for label, planned := range map[string][]string{"nothing": {}, "another assembly": {"Beta"}} { + t.Run(label, func(t *testing.T) { + project := newFastPathProject(t, fastPathMinimumSources) + project.recordBaseline(t) + before := project.outputSnapshot(t) + full := project.plan + project.plan = project.withOnlyUnits(planned...) + project.run(t, newCachedSchedulerRecorder(planned...), false) + project.plan = full + + if after := project.outputSnapshot(t); !reflect.DeepEqual(after, before) { + t.Fatalf("expected the outputs, result, and baseline to stay, got %v then %v", before, after) + } + project.editBody(t, 0, "edited") + project.runFastChecked(t) + }) + } +} + // Verifies that a baseline agreeing with every source but disagreeing with the current key is // dropped, and the unit compiles in full. func TestZeroChangedFilesDropsBaselineAndFallsBack(t *testing.T) { diff --git a/docs/compile-check.md b/docs/compile-check.md index d97acce0f..6f6f0f3c1 100644 --- a/docs/compile-check.md +++ b/docs/compile-check.md @@ -215,8 +215,9 @@ build - does not call the worker again: it reports what the previous check repor Otherwise the assembly is compiled in full as before, and `FastPathFallbacks` says why: - `no baseline: no full compile of this assembly is on record` (none ran yet, a later run - skipped the assembly, which removes its result and baseline, or an input changed while - the last full compile ran, so it left no record; `FastPathBaselineNotes` of that run says which) + picked the assembly up only because a reference changed and then skipped it, which removes its + result and baseline, or an input changed while the last full compile ran, so it left no record; + `FastPathBaselineNotes` of that run says which) - `no baseline: the last full compile had errors; the first full compile without errors records one` (a full compile that fails drops the baseline an earlier one left, and the assembly is compiled in full until a compile succeeds) @@ -256,11 +257,15 @@ So the first body edit is compiled in full more often than it looks: and the first body edit is checked as usual. Only when that run leaves the reference out, so it reads Unity's build instead, does the first body edit of an assembly referencing it fall back with `inputs other than source contents changed: references`. -- A run that skips an assembly because nothing it compiles from changed removes its result and - baseline, so its next body edit is compiled in full. A run that blocks it because an assembly it - references has errors keeps them: the next run checks them against the inputs and output hashes - they were recorded with before using them, so a reference that comes back the same leaves the - assembly reused or checked on its changed files, and one that comes back changed compiles it. +- An assembly a run leaves out because nothing it compiles from changed keeps its result and + baseline, so its next body edit is checked against them. An assembly a run picks up only because + a reference changed loses its result and baseline either way: compiled, it records no baseline, + and left out, because every such reference kept its public surface or changed only names the + assembly never writes, its result and baseline are removed. The next body edit of that assembly + is compiled in full. A run that blocks an assembly because one it references has errors keeps + its result and baseline: the next run checks them against the inputs and output hashes they were + recorded with before using them, so a reference that comes back the same leaves the assembly + reused or checked on its changed files, and one that comes back changed compiles it. - A full compile while the assembly still has errors, whether a `--full` run or a run that fell back to one, drops its baseline, so the run after the fix is compiled in full. Running `--full` once the errors are fixed keeps it.