mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
Make bash integration tests more robust on macOS
This commit is contained in:
@@ -306,7 +306,7 @@ PS1="{ps1}"
|
|||||||
self.ae(pty.screen_contents(), f'{ps1}printf "%s^G%s" "a" "b"\nab{ps1}')
|
self.ae(pty.screen_contents(), f'{ps1}printf "%s^G%s" "a" "b"\nab{ps1}')
|
||||||
self.assertTrue(pty.screen.last_reported_cwd.decode().endswith(self.home_dir))
|
self.assertTrue(pty.screen.last_reported_cwd.decode().endswith(self.home_dir))
|
||||||
pty.send_cmd_to_child('echo $HISTFILE')
|
pty.send_cmd_to_child('echo $HISTFILE')
|
||||||
pty.wait_till(lambda: '.bash_history' in pty.screen_contents())
|
pty.wait_till(lambda: '.bash_history' in pty.screen_contents().replace('\n', ''))
|
||||||
q = os.path.join(self.home_dir, 'testing-cwd-notification-🐱')
|
q = os.path.join(self.home_dir, 'testing-cwd-notification-🐱')
|
||||||
os.mkdir(q)
|
os.mkdir(q)
|
||||||
pty.send_cmd_to_child(f'cd {q}')
|
pty.send_cmd_to_child(f'cd {q}')
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"kitty/tools/cli"
|
"kitty/tools/cli"
|
||||||
|
"kitty/tools/tty"
|
||||||
"kitty/tools/tui"
|
"kitty/tools/tui"
|
||||||
"kitty/tools/tui/shell_integration"
|
"kitty/tools/tui/shell_integration"
|
||||||
)
|
)
|
||||||
@@ -68,6 +69,9 @@ func main(args []string, opts *Options) (rc int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debugprintln = tty.DebugPrintln
|
||||||
|
var _ = debugprintln
|
||||||
|
|
||||||
func EntryPoint(root *cli.Command) *cli.Command {
|
func EntryPoint(root *cli.Command) *cli.Command {
|
||||||
sc := root.AddSubCommand(&cli.Command{
|
sc := root.AddSubCommand(&cli.Command{
|
||||||
Name: "run-shell",
|
Name: "run-shell",
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ func RunShell(shell_cmd []string, shell_integration_env_var_val, cwd string) (er
|
|||||||
shell_env = env
|
shell_env = env
|
||||||
}
|
}
|
||||||
exe := shell_cmd[0]
|
exe := shell_cmd[0]
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" && os.Getenv("KITTY_RUNNING_BASH_INTEGRATION_TEST") != "" {
|
||||||
// ensure shell runs in login mode. On macOS lots of people use ~/.bash_profile instead of ~/.bashrc
|
// ensure shell runs in login mode. On macOS lots of people use ~/.bash_profile instead of ~/.bashrc
|
||||||
// which means they expect the shell to run in login mode always. Le Sigh.
|
// which means they expect the shell to run in login mode always. Le Sigh.
|
||||||
shell_cmd[0] = "-" + filepath.Base(shell_cmd[0])
|
shell_cmd[0] = "-" + filepath.Base(shell_cmd[0])
|
||||||
@@ -184,6 +184,9 @@ func RunShell(shell_cmd []string, shell_integration_env_var_val, cwd string) (er
|
|||||||
return unix.Exec(utils.FindExe(exe), shell_cmd, env)
|
return unix.Exec(utils.FindExe(exe), shell_cmd, env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debugprintln = tty.DebugPrintln
|
||||||
|
var _ = debugprintln
|
||||||
|
|
||||||
func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) {
|
func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) {
|
||||||
exe := utils.FindExe(cmd[0])
|
exe := utils.FindExe(cmd[0])
|
||||||
c := exec.Command(exe, cmd[1:]...)
|
c := exec.Command(exe, cmd[1:]...)
|
||||||
|
|||||||
@@ -328,8 +328,7 @@ func bash_setup_func(shell_integration_dir string, argv []string, env map[string
|
|||||||
argv = slices.Insert(argv, 1, `--posix`)
|
argv = slices.Insert(argv, 1, `--posix`)
|
||||||
|
|
||||||
if bashrc := os.Getenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`); bashrc != `` {
|
if bashrc := os.Getenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`); bashrc != `` {
|
||||||
// prevent bash from source /etc/profile which is not under our control
|
// prevent bash from sourcing /etc/profile which is not under our control
|
||||||
os.Unsetenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`)
|
|
||||||
env[`KITTY_BASH_INJECT`] += ` posix`
|
env[`KITTY_BASH_INJECT`] += ` posix`
|
||||||
env[`KITTY_BASH_POSIX_ENV`] = bashrc
|
env[`KITTY_BASH_POSIX_ENV`] = bashrc
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user