Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dfd4efd782 | |||
| a849c26509 |
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -82,6 +83,32 @@ func TestGrepGuardAllowsShortWindow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompletionAllEntrypointsAndShells(t *testing.T) {
|
||||||
|
// scripts/build-rpm.sh runs "<name> completion <shell>" 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) {
|
func TestEntrypointDispatch(t *testing.T) {
|
||||||
root := newRootCmd()
|
root := newRootCmd()
|
||||||
names := map[string]bool{}
|
names := map[string]bool{}
|
||||||
|
|||||||
Regular → Executable
Reference in New Issue
Block a user