fix(build): restore the go fix fixpoint, and give the formatter one owner
A "reduce Taskfile bloat" refactor (2e00777f) removed the fixpoint loop from
task fmt and deleted the guard test that proved it, putting the tree back to a
single go fix pass with nothing left to notice. One pass is not a fixpoint:
stditerators rewrites `for i := range t.NumFields()` into a field iterator that
copies its loop variable, and forvar only deletes that copy on the following
pass, leaving a tree copyloopvar rejects. archie-core-wwho regressed silently.
Restore the loop and the guard. The deploy workflow has always inlined its own
single `go fix ./...`, which is how the same hazard reached CI as a spurious
git-diff failure rather than a lint error (archie-core-6kda); it now calls task
fmt, the one owner of the formatter sequence, and its guard rejects an inline
copy so the split cannot come back.
This commit is contained in:
4 files changed
+73
-6
No files matched your search
@@ -73,7 +73,10 @@ func TestFormattingUsesOneConfiguredWriter(t *testing.T) {
|
||||
}
|
||||
fmtTask := taskfile[fmtStart:fmtEnd]
|
||||
|
||||
const applyFix = "go fix ./..."
|
||||
const (
|
||||
applyFix = "go fix ./..."
|
||||
verifyFix = "go fix -diff ./..."
|
||||
)
|
||||
fix := strings.Index(fmtTask, applyFix)
|
||||
format := strings.Index(fmtTask, "golangci-lint fmt")
|
||||
if fix < 0 || format < 0 || fix > format {
|
||||
@@ -82,6 +85,26 @@ func TestFormattingUsesOneConfiguredWriter(t *testing.T) {
|
||||
if strings.Contains(fmtTask, "gofumpt -") {
|
||||
t.Error("fmt task bypasses the configured formatter set with standalone gofumpt")
|
||||
}
|
||||
// One go fix pass is not a fixpoint: stditerators rewrites
|
||||
// `for i := range t.NumField()` into a field iterator that copies its loop
|
||||
// variable, and forvar only deletes that copy on the following pass. A tree
|
||||
// that stops after one pass is therefore one copyloopvar rejects, so fmt has
|
||||
// to keep applying passes and prove the plateau with a dry run that exits
|
||||
// clean only when nothing is left to fix.
|
||||
//
|
||||
// This assertion was deleted by a "reduce Taskfile bloat" commit along with
|
||||
// the loop it guarded, which put the tree back to a single pass with nothing
|
||||
// to notice. It is the reason the loop is checked for here rather than only
|
||||
// the presence of a go fix invocation.
|
||||
if !strings.Contains(fmtTask, verifyFix) {
|
||||
t.Error("fmt task does not prove that repeated go fix passes have reached a fixpoint")
|
||||
}
|
||||
if got := strings.Count(fmtTask, applyFix); got != 1 {
|
||||
t.Errorf("fmt task applies go fix %d times inline, want 1: the repetition belongs to the fixpoint loop", got)
|
||||
}
|
||||
if got := strings.Count(fmtTask, verifyFix); got != 1 {
|
||||
t.Errorf("fmt task verifies the go fix fixpoint %d times, want 1", got)
|
||||
}
|
||||
if got, owned := strings.Count(taskfile, applyFix), strings.Count(fmtTask, applyFix); got != owned {
|
||||
t.Errorf("Taskfile invokes go fix %d times, %d of them through task fmt: formatting has one owner", got, owned)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user