Say a build source only for the trunk's head, and hold what C, assembly and a new go.mod reach (hq ADR 0267, review)
mesh/merge-gate pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus step; every machine composes with the change as it…
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request

A hand build of an older trunk commit said a closure lacking what was
imported since, and the planner would have mapped the next merge onto it.
C and assembly beside Go may include files below their directory, and a
go.mod made above a package moves it out of its module: each is now held.
This commit is contained in:
jochen
2026-10-10 03:11:06 +02:00
parent 4d1b81b6cb
commit abe5f7dc17
5 changed files with 146 additions and 15 deletions
+20 -2
View File
@@ -47,7 +47,7 @@ var aProgram = map[string]string{
"lib/lib.go": "package lib\n\nconst X = 1\n",
"lib/lib_plan9.go": "//go:build plan9\n\npackage lib\n\nimport _ \"example.com/fix/plan9only\"\n",
"lib/lib_test.go": "package lib\n\nimport _ \"example.com/fix/testonly\"\n",
"lib/lib_amd64.s": "",
"emb/emb_amd64.s": "",
"lib/sub/sub.go": "package sub\n",
"plan9only/p.go": "package plan9only\n",
"testonly/t.go": "package testonly\n",
@@ -74,7 +74,7 @@ func TestAGoProgramsBuildSourceIsItsImportClosure(t *testing.T) {
{"cmd/prog/main.go", true, "the program itself"},
{"cmd/prog/helper.go", true, "a file added to the program's package"},
{"lib/lib.go", true, "a package it imports"},
{"lib/lib_amd64.s", true, "assembly beside a package's Go"},
{"emb/emb_amd64.s", true, "assembly beside a package's Go"},
{"lib/lib_plan9.go", true, "a file one system builds"},
{"plan9only/p.go", true, "what a file one system builds imports"},
{"emb/static/index.html", true, "an embedded file"},
@@ -172,6 +172,8 @@ func TestABuildSourceThatCannotBeReadIsRefused(t *testing.T) {
"go.mod": "module x\n\nreplace y => ../y\n", "p/main.go": "package main\n\nimport _ \"y\"\n"}, "p", "outside"},
{"a cgo header outside the directory", map[string]string{
"go.mod": "module x\n", "p/main.go": "package main\n\n// #include \"../h/h.h\"\nimport \"C\"\n"}, "p", "cgo"},
{"an assembly include above its directory", map[string]string{"go.mod": "module x\n", "p/main.go": "package main\n",
"p/a_amd64.s": "#include \"../h/textflag.h\"\n"}, "p", "outside"},
{"a file that does not parse", map[string]string{"go.mod": "module x\n", "p/main.go": "package main\n\nimport (\n"},
"p", "main.go"},
{"a package that leaves the tree", map[string]string{"go.mod": "module x\n"}, "../elsewhere", "leaves"},
@@ -286,3 +288,19 @@ func TestThisRepositorysProgramsHaveBuildSourcesOfTheirOwn(t *testing.T) {
}
}
}
// C or assembly beside Go holds its package's directory whole — an include may name a file below it — and a
// go.mod made between the module's root and a package is a change.
func TestNativeSourcesHoldTheirDirectoryWhole(t *testing.T) {
got, err := GoBuildSource(aGoTree(t, map[string]string{"go.mod": "module x\n", "cmd/p/main.go": "package main\n\nimport _ \"x/lib/asm\"\n",
"lib/asm/a.go": "package asm\n", "lib/asm/a_amd64.s": "#include \"inc/textflag.h\"\n", "lib/asm/inc/textflag.h": ""}), "cmd/p")
if err != nil {
t.Fatal(err)
}
for file, want := range map[string]bool{"lib/asm/inc/textflag.h": true, "lib/asm/a_amd64.s": true, "lib/go.mod": true,
"lib/asm/go.mod": true, "cmd/go.mod": true, "other/go.mod": false} {
if SourceHolds(got, file) != want {
t.Errorf("%s: held %v, wanted %v (%v)", file, !want, want, got)
}
}
}