Files
FWS-Kitty/kittens/choose_files/main_test.go
T
BlackAngelTV 3d174c45a4 chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
2026-11-04 11:35:59 +01:00

37 lines
1.0 KiB
Go

// License: GPLv3 Copyright: 2026, Kovid Goyal, <kovid at kovidgoyal.net>
package choose_files
import (
"path/filepath"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
)
func TestShellOutput(t *testing.T) {
paths := []string{"simple", "a path", "a;command", "*.txt", "~root", "a>output", `a\b`, "it's"}
actual, err := shlex.Split(shell_output(paths))
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(paths, actual); diff != "" {
t.Fatalf("Shell output did not round-trip paths:\n%s", diff)
}
if q := shell_output([]string{"simple", "a/b"}); q != "simple a/b" {
t.Fatalf("Shell-safe paths were unnecessarily quoted: %q", q)
}
original_cwd := default_cwd
default_cwd = t.TempDir()
t.Cleanup(func() { default_cwd = original_cwd })
relative, err := shlex.Split(for_shell_relative(filepath.Join(default_cwd, "a;command")))
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff([]string{"a;command"}, relative); diff != "" {
t.Fatalf("Shell-relative output did not round-trip the path:\n%s", diff)
}
}