claude: fold in old sow-tools
This commit is contained in:
@@ -55,8 +55,11 @@ func TestUnknownBuilderFailsUsage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEveryBuilderFailsClosed(t *testing.T) {
|
||||
func TestUnwiredBuilderFailsClosed(t *testing.T) {
|
||||
for _, b := range Registry {
|
||||
if b.Wired {
|
||||
continue
|
||||
}
|
||||
var out, errw bytes.Buffer
|
||||
// Via dispatcher.
|
||||
if code := run([]string{b.Name}, &out, &errw); code != exitUnwired {
|
||||
@@ -74,6 +77,28 @@ func TestEveryBuilderFailsClosed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWiredBuilderRejectsBadInvocation(t *testing.T) {
|
||||
for _, b := range Registry {
|
||||
if !b.Wired {
|
||||
continue
|
||||
}
|
||||
// No subcommand is a usage error (it must never silently delegate).
|
||||
var out, errw bytes.Buffer
|
||||
if code := runBuilder(b.Name, nil, &out, &errw); code != exitUsage {
|
||||
t.Errorf("crucible %s (no subcommand): exit=%d want %d", b.Name, code, exitUsage)
|
||||
}
|
||||
// Unknown subcommand is a usage error, not a delegate.
|
||||
out.Reset()
|
||||
errw.Reset()
|
||||
if code := runBuilder(b.Name, []string{"frobnicate"}, &out, &errw); code != exitUsage {
|
||||
t.Errorf("crucible %s frobnicate: exit=%d want %d", b.Name, code, exitUsage)
|
||||
}
|
||||
if !strings.Contains(errw.String(), "unknown subcommand") {
|
||||
t.Errorf("crucible %s frobnicate: stderr=%q", b.Name, errw.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderHelpIsOK(t *testing.T) {
|
||||
for _, b := range Registry {
|
||||
var out, errw bytes.Buffer
|
||||
@@ -85,3 +110,28 @@ func TestBuilderHelpIsOK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every legacy command named in command-surface.md must have exactly one
|
||||
// canonical home (Builder.Legacy), so the migrated surface has no gaps or
|
||||
// ambiguous homes.
|
||||
func TestLegacyCommandsHaveExactlyOneHome(t *testing.T) {
|
||||
legacy := []string{
|
||||
"build", "build-module", "extract", "validate", "compare",
|
||||
"build-haks", "apply-hak-manifest",
|
||||
"validate-topdata", "build-topdata", "build-top-package", "compare-topdata", "convert-topdata",
|
||||
"build-wiki", "deploy-wiki",
|
||||
}
|
||||
for _, cmd := range legacy {
|
||||
homes := 0
|
||||
for _, b := range Registry {
|
||||
for _, c := range b.Legacy {
|
||||
if c == cmd {
|
||||
homes++
|
||||
}
|
||||
}
|
||||
}
|
||||
if homes != 1 {
|
||||
t.Errorf("legacy command %q has %d canonical homes, want 1", cmd, homes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user