From a849c26509328b10d667d4cdb153b3204a2a0148 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sun, 23 Aug 2026 17:29:23 +1000 Subject: [PATCH] Make build-rpm.sh executable and test completion generation The v0.1.0 tag pipeline failed at the package step: build-rpm.sh was committed mode 100644, so CI's ./scripts/build-rpm.sh invocation died with permission denied before any completions were generated. - Restore the executable bit on scripts/build-rpm.sh (mode 100755, matching node-lookup) - Add TestCompletionAllEntrypointsAndShells covering bash/zsh/fish completion generation through the argv[0] dispatch for all four entrypoints (chlog/chcat/chtail/chgrep) --- main_test.go | 27 +++++++++++++++++++++++++++ scripts/build-rpm.sh | 0 2 files changed, 27 insertions(+) mode change 100644 => 100755 scripts/build-rpm.sh diff --git a/main_test.go b/main_test.go index db68ca0..6895ce1 100644 --- a/main_test.go +++ b/main_test.go @@ -1,6 +1,7 @@ package main import ( + "os" "strings" "testing" "time" @@ -82,6 +83,32 @@ func TestGrepGuardAllowsShortWindow(t *testing.T) { } } +func TestCompletionAllEntrypointsAndShells(t *testing.T) { + // scripts/build-rpm.sh runs " completion " for every + // entrypoint; guard that each argv[0]-dispatched command tree exposes a + // working completion subcommand for all three packaged shells. + for _, name := range []string{"chlog", "chcat", "chtail", "chgrep"} { + for _, shell := range []string{"bash", "zsh", "fish"} { + t.Run(name+"/"+shell, func(t *testing.T) { + orig := os.Args + os.Args = []string{name} + defer func() { os.Args = orig }() + cmd := entrypoint() + var out strings.Builder + cmd.SetOut(&out) + cmd.SetErr(&out) + cmd.SetArgs([]string{"completion", shell}) + if err := cmd.Execute(); err != nil { + t.Fatalf("%s completion %s: %v", name, shell, err) + } + if !strings.Contains(out.String(), name) { + t.Fatalf("%s completion %s output does not mention %q", name, shell, name) + } + }) + } + } +} + func TestEntrypointDispatch(t *testing.T) { root := newRootCmd() names := map[string]bool{} diff --git a/scripts/build-rpm.sh b/scripts/build-rpm.sh old mode 100644 new mode 100755