From 86a6685446fbf8ba9532bda21fc631f1aa9d94ae Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 5 Jan 2025 20:36:32 +0530 Subject: [PATCH] Add mock for failing test --- kittens/ssh/utils_test.go | 5 ++++- tools/config/api.go | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kittens/ssh/utils_test.go b/kittens/ssh/utils_test.go index 09197acbb..a36c0df88 100644 --- a/kittens/ssh/utils_test.go +++ b/kittens/ssh/utils_test.go @@ -9,6 +9,7 @@ import ( "path/filepath" "testing" + "kitty/tools/config" "kitty/tools/utils/shlex" "github.com/google/go-cmp/cmp" @@ -66,8 +67,10 @@ func TestParseSSHArgs(t *testing.T) { func TestRelevantKittyOpts(t *testing.T) { tdir := t.TempDir() path := filepath.Join(tdir, "kitty.conf") + config.OverrideEffectiveConfigPath = path + defer func() { config.OverrideEffectiveConfigPath = "" }() os.WriteFile(path, []byte("term XXX\nshell_integration changed\nterm abcd"), 0o600) - rko := read_relevant_kitty_opts(path) + rko := read_relevant_kitty_opts() if rko.Term != "abcd" { t.Fatalf("Unexpected TERM: %s", RelevantKittyOpts().Term) } diff --git a/tools/config/api.go b/tools/config/api.go index 12f431546..2ed51c95a 100644 --- a/tools/config/api.go +++ b/tools/config/api.go @@ -401,10 +401,12 @@ func ReloadConfigInKitty(in_parent_only bool) error { return nil } +var OverrideEffectiveConfigPath string + func ReadKittyConfig(line_handler func(key, val string) error) error { - kitty_conf_path := "" kp := os.Getenv("KITTY_PID") - if _, err := strconv.Atoi(kp); err == nil { + kitty_conf_path := OverrideEffectiveConfigPath + if _, err := strconv.Atoi(kp); err == nil && kitty_conf_path == "" { effective_config_path := filepath.Join(utils.CacheDir(), "effective-config", kp) if unix.Access(effective_config_path, unix.R_OK) == nil { kitty_conf_path = effective_config_path