solutions: exit 3 is "interrupted", "not found" moves to 7

The family convention (docs/program-conventions.md) gives 3 to a
command stopped by SIGINT/SIGTERM (owner decision 2026-12-01 to unify).
A cancelled context now exits 3; yetano-solutions also stops on SIGTERM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-12-01 13:21:10 +01:00
1 parent 4fb9bf9a5a
commit c8a219a84b
3 files changed
+34 -7

No files matched your search

+19
View File
@@ -147,3 +147,22 @@ func TestInteractiveWizard(t *testing.T) {
t.Error("export did not write the configuration")
}
}
// Ctrl-C: a cancelled context is exit 3, the family-wide "interrupted"
// (docs/program-conventions.md); "not found" moved to 7 for it.
func TestInterrupted(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
var out, errb bytes.Buffer
code := Run(ctx, []string{"solution", "show", "nope"}, Env{
Stdin: strings.NewReader(""), Stdout: &out, Stderr: &errb,
Program: "yetano-solutions", StoreDir: t.TempDir(), Catalogs: []string{"../engine/testdata/cat"},
Getenv: func(string) string { return "" },
})
if code != ExitInterrupted || ExitInterrupted != 3 || ExitNotFound != 7 {
t.Fatalf("cancelled: exit %d (%s)", code, errb.String())
}
if r := run(t, t.TempDir(), "solution", "show", "nope"); r.code != 7 {
t.Fatalf("not found: exit %d", r.code)
}
}