mesh/delivery closed: a newer head of the same pull request
mesh/check failed: ace: novox/mesh-catalog#505 does not merge into the trunk: files in conflict: .gitignore | a324c03233fc on da29f77b1081 | unit 1245…
52 lines
2.2 KiB
Go
52 lines
2.2 KiB
Go
package noscripts
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// builtKnown are the compiled programs tracked on main the day the refusal below began (2026-10-26), each to be removed
|
|
// from the tree; the list only shrinks.
|
|
var builtKnown = map[string]bool{
|
|
"modules/forticlient/cmd/forticlient-tools/forticlient-tools": true,
|
|
"modules/networkmanager/uplink-tools": true,
|
|
}
|
|
|
|
// The catalogue's checks are Go tests (novox/hq ADR 0529 clause 5, ADR 0445): the checker runs every nested Go module's tests by
|
|
// the language's convention and no script at the root says what else to run. A script back at the root would be a check nobody
|
|
// runs (ADR 0503 §3: since R4e the checker has not run them), so it is refused.
|
|
func TestNoScriptOfTheOldCheckStandsAtTheRoot(t *testing.T) {
|
|
for _, name := range []string{"merge-check.sh", "merge-check-typescript.sh", "check-nested-modules.sh"} {
|
|
if _, err := os.Stat(filepath.Join("..", "..", name)); !errors.Is(err, os.ErrNotExist) {
|
|
t.Errorf("%s stands at the catalogue's root (%v): what it ran is a Go test in checks/ or a step of the build module", name, err)
|
|
}
|
|
}
|
|
|
|
// Nor does a compiled program stand in the tree (issue 1126: a `go build` in place committed twice in one day, 5 and
|
|
// 6 MB each, which only a rewrite of the branch takes out of its history): the build module builds what runs.
|
|
out, err := exec.Command("git", "-C", filepath.Join("..", ".."), "ls-files", "-z").Output()
|
|
if err != nil {
|
|
t.Fatalf("the tracked files cannot be listed, so no compiled program can be refused: %v", err)
|
|
}
|
|
for _, name := range bytes.Split(bytes.TrimRight(out, "\x00"), []byte{0}) {
|
|
f, err := os.Open(filepath.Join("..", "..", string(name)))
|
|
if err != nil {
|
|
continue // a tracked file the checkout lacks (deleted, not yet committed)
|
|
}
|
|
magic := make([]byte, 4)
|
|
n, _ := f.Read(magic)
|
|
f.Close()
|
|
if n == 4 && string(magic) == "\x7fELF" && !builtKnown[string(name)] {
|
|
t.Errorf("%s is a compiled program: remove it with git rm --cached, and build with -o outside the tree", name)
|
|
}
|
|
delete(builtKnown, string(name))
|
|
}
|
|
for name := range builtKnown {
|
|
t.Errorf("%s is no longer tracked: take it off builtKnown", name)
|
|
}
|
|
}
|