A generated file is checked against its generator, and two had stopped matching (#1034) - #1124
Merged
Merged
Conversation
…d matching Nothing rebuilt the checked-in generated files and compared, so a template could stop matching its output and the build stayed green -- the file only being discovered to be unregenerable the next time somebody actually tried. That had already happened once, to `EquationSystemFunctionPattern.txt`, repaired by #1029. It had happened twice. `TupleToIntervalTest.txt` still named `MathS.Matrices.Interval`, which does not exist, so regenerating `TupleToIntervalTest.cs` produced eighteen CS0117 errors -- measured, not inferred. The generator had also drifted on the namespace, writing `UnitTest.Extensions` where the test project uses `AngouriMath.Tests.Extensions`, and had lost the `Area` trait every test class here carries so that `dotnet test --filter` can select by area. All three are repaired. **And two of the three T4 templates did not emit the copyright header**, which is worse than cosmetic: IDE0073 is an error in this repository, so regenerating either of them produced a file that failed the build outright. The issue proposed excluding the header block when diffing; emitting it is better, because then the generated file is the committed file and there is no exclusion that could quietly grow to hide a real difference. `MathAllMethods.tt` already emitted it and already reproduced exactly, so this makes the other two match the one that worked -- BOM included, which that file does not have either and which no `.editorconfig` rule asks for. `Sources/Utils/regenerate_all.sh` regenerates everything in place. The three T4 templates are read out of `AngouriMath.csproj` rather than listed in the script, because a list written twice is a list that drifts, and this one would drift in the direction of covering less. It resolves paths from its own location rather than from the working directory, and it looks `t4` up rather than assuming it is on PATH -- `dotnet tool install -g dotnet-t4` installs a binary called `t4`, so `dotnet t4` fails with a message that reads as a typo. `GeneratedFilesUpToDate.yml` runs it and fails on any difference, printing the diff rather than "files differ". Demonstrated by breaking a template without regenerating its output: the job's diff step exits 1 and names `TupleToIntervalTest.cs`. The ANTLR parser keeps its own job, `GrammarUpToDate.yml`, because it needs a Java runtime where this needs a dotnet tool -- so neither goes red for the other's reason. Part of #1034.
Collaborator
Author
Criteria 1 and 2, demonstrated on CI rather than locally#1125 is this branch with one line of The failing run. Its output, which is criterion 2 — the file is named and the diff is shown, not "files differ": And the same job on this PR passes in 1m25s, so the gate starts from a clean baseline rather than from a diff nobody can fix. #1125 is closed and its branch will be deleted; it exists only as the evidence for this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1034.
The issue was right, and it had happened again
Nothing rebuilt the checked-in generated files and compared, so a template could stop matching its output and the build stayed green.
EquationSystemFunctionPattern.txtwas the first case, repaired by #1029. There was a second one live onmaster:TupleToIntervalTest.txtstill namedMathS.Matrices.Interval, which does not exist. RegeneratingTupleToIntervalTest.csproduced eighteenCS0117errors — measured, not inferred:The generator had drifted twice more: it wrote namespace
UnitTest.Extensionswhere the test project usesAngouriMath.Tests.Extensions, and it had lost the[Trait("Area", …)]every test class here carries sodotnet test --filtercan select by area. All three are repaired, and the regenerated file builds and passes its 18 tests.Two T4 templates produced files that failed the build
The issue proposed excluding the copyright header when diffing, since no template emitted it. That understates it: IDE0073 is an error in this repository, so regenerating either
CompilationExtensions.ttorCompile.Linq.Definition.ttproduced a file that would not compile.So they emit it now instead. That is better than an exclusion on two counts: it fixes a real break rather than agreeing to ignore it, and it means the gate has no exclusions at all — nothing that could quietly grow to hide a real difference, which is the issue's own acceptance criterion 3.
MathAllMethods.ttalready emitted the header and already reproduced exactly, so this makes the other two match the one that worked. BOM included: that file has none either, and no.editorconfigrule asks for one.The gate
Sources/Utils/regenerate_all.shregenerates everything in place, andGeneratedFilesUpToDate.ymlruns it and fails on any difference, printing the diff rather than "files differ".Three details that are deliberate:
AngouriMath.csproj, not written in the script. A list written twice is a list that drifts, and this one would drift in the direction of covering less.t4is looked up, not assumed.dotnet tool install -g dotnet-t4installs a binary calledt4, sodotnet t4fails with "You misspelled a built-in dotnet command" — a message that reads as the caller's typo rather than a missing tool.ANTLR keeps its own job,
GrammarUpToDate.yml, because it needs a Java runtime where this needs a dotnet tool — so neither goes red for the other's reason. (That job already exists and already covers the parser, so the issue's fifth row is done.)Acceptance criteria
demo/generated-files-gate-goes-red, which editsTupleToIntervalTest.txtand nothing else. Locally the same edit givesexit=1and namesSources/Tests/UnitTests/Convenience/TupleToIntervalTest.cs.git --no-pager diffafter the::error::lines.Failed: 0, Passed: 9098, Skipped: 14locally on net10.0, with every generated file regenerated from scratch.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura