From d224b74ff1b942a9fe504a2d54bad15601eed2d4 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 26 Oct 2026 22:13:01 +0100 Subject: [PATCH] mesh-build-go: a marked package's digest hashes every file of its own directory, Go files its build tags exclude too (issue 1936) go list leaves a file its build tags exclude (an integration test) in IgnoredGoFiles, which the digest did not hash; mesh-provisioner-client's unit test globs *_test.go and reads two of them, so a change there reused a stale unit pass. Review finding F2 on ba49a7f0. --- .../mesh-build-go/cmd/mesh-build-go/digest.go | 18 ++++++++---------- .../cmd/mesh-build-go/digest_test.go | 13 +++++++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/digest.go b/modules/mesh-build-go/cmd/mesh-build-go/digest.go index ae275800..0e0133e2 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/digest.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/digest.go @@ -44,9 +44,10 @@ const besideVariable = "MESH_CHECK_BESIDE" // with ? names a path whose absence is what the tests read (a file that must not be there): it may match nothing. // // The digest then hashes, besides what the toolchain lists, every line of the marker, every file it names (under its -// path in the tree, by content) and every file of the package's own directory. A marker that lists nothing, a line -// that is not a clean relative path, or a line without ? that matches nothing makes the package one that is never kept -// (its digest a fresh random hex): a list nobody can trust keeps nothing. The exact fix, the files a test opened kept +// path in the tree, by content) and every file of the package's own directory, Go files included (a file its build tags +// exclude is one go list does not hash). A marker that lists nothing, a line that is not a clean relative path, or a +// line without ? that matches nothing makes the package one that is never kept (its digest a fresh random hex): a list +// nobody can trust keeps nothing. The exact fix, the files a test opened kept // from the Go test log with each verdict, replaces the lists (issue 1936). const ReadsOutsideMarker = "reads-outside" @@ -557,13 +558,10 @@ func declaredReads(tree string, root *goPackage, cache map[string]string) (lines } } } - // The package's own files that are not Go source: its lists, its marker. A catalogue module's are its module's too. - err = walkFiles(root.Dir, func(path string) error { - if strings.HasSuffix(path, ".go") { - return nil - } - return add(path) - }) + // Every file of the package's own directory: its lists, its marker, and its Go files too, since go list leaves a + // file its build tags exclude (an integration test a unit test globs) out of what the digest hashes. A file the + // toolchain lists is hashed twice, which changes nothing. + err = walkFiles(root.Dir, add) return lines, "", err } diff --git a/modules/mesh-build-go/cmd/mesh-build-go/digest_test.go b/modules/mesh-build-go/cmd/mesh-build-go/digest_test.go index 1101191d..a6dac3a4 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/digest_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/digest_test.go @@ -241,12 +241,13 @@ func TestAPackageWithTheReadsOutsideMarkerIsKeptOnlyByWhatItLists(t *testing.T) file, text string moves bool }{ - {"other.md", "changed\n", false}, // outside the list - {"d/d.go", "package d\n\n// D.\n", false}, // a package c's tests do not reach - {"docs/one.md", "changed\n", true}, // a listed file - {"docs/two.md", "new\n", true}, // a new file the glob matches - {"gone", "here\n", true}, // a path whose absence was read - {"c/note.txt", "changed\n", true}, // the package's own file that is not Go + {"other.md", "changed\n", false}, // outside the list + {"d/d.go", "package d\n\n// D.\n", false}, // a package c's tests do not reach + {"docs/one.md", "changed\n", true}, // a listed file + {"docs/two.md", "new\n", true}, // a new file the glob matches + {"gone", "here\n", true}, // a path whose absence was read + {"c/note.txt", "changed\n", true}, // the package's own file that is not Go + {"c/x_integration_test.go", "//go:build integration\n\npackage c\n", true}, // a Go file its build tags leave out (go list's IgnoredGoFiles) } { edit(t, tree, step.file, step.text) after := digests(t, m, "unit")