b84e0dd1bd
gates / gates (push) Successful in 19s
Found live 2026-10-04: the OS leg's debug action could not run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Every mode the dispatcher (`switch selftest.mode`) runs must be ACCEPTED by the --selftest flag. Found live
|
|
// 2026-10-04: --selftest=os-update had a dispatch case and a function but the flag's allow-list refused it, so the
|
|
// debug action could not run. Red-proof: drop the "os-update" case from selftestFlag.Set and this fails.
|
|
func TestSelftestFlag_AcceptsEveryDispatchedMode(t *testing.T) {
|
|
src, err := os.ReadFile("main.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := string(src)
|
|
i := strings.Index(s, "switch selftest.mode {")
|
|
if i < 0 {
|
|
t.Fatal("dispatch switch not found")
|
|
}
|
|
block := s[i:]
|
|
block = block[:strings.Index(block, "\n\t}\n")]
|
|
modes := regexp.MustCompile(`(?m)^\tcase "([a-z-]+)":`).FindAllStringSubmatch(block, -1)
|
|
if len(modes) < 5 {
|
|
t.Fatalf("parsed only %d dispatch cases — the parser is wrong", len(modes))
|
|
}
|
|
var bad []string
|
|
for _, m := range modes {
|
|
var f selftestFlag
|
|
if err := f.Set(m[1]); err != nil {
|
|
bad = append(bad, m[1])
|
|
}
|
|
}
|
|
if len(bad) > 0 {
|
|
t.Fatalf("dispatched but refused by --selftest: %v", bad)
|
|
}
|
|
}
|