mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Make bash integration tests more robust on macOS
This commit is contained in:
parent
1293ee60e0
commit
fa11858a72
4 changed files with 10 additions and 4 deletions
|
|
@ -306,7 +306,7 @@ PS1="{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))
|
||||
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-🐱')
|
||||
os.mkdir(q)
|
||||
pty.send_cmd_to_child(f'cd {q}')
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"kitty/tools/cli"
|
||||
"kitty/tools/tty"
|
||||
"kitty/tools/tui"
|
||||
"kitty/tools/tui/shell_integration"
|
||||
)
|
||||
|
|
@ -68,6 +69,9 @@ func main(args []string, opts *Options) (rc int, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
var debugprintln = tty.DebugPrintln
|
||||
var _ = debugprintln
|
||||
|
||||
func EntryPoint(root *cli.Command) *cli.Command {
|
||||
sc := root.AddSubCommand(&cli.Command{
|
||||
Name: "run-shell",
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ func RunShell(shell_cmd []string, shell_integration_env_var_val, cwd string) (er
|
|||
shell_env = env
|
||||
}
|
||||
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
|
||||
// which means they expect the shell to run in login mode always. Le Sigh.
|
||||
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)
|
||||
}
|
||||
|
||||
var debugprintln = tty.DebugPrintln
|
||||
var _ = debugprintln
|
||||
|
||||
func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) {
|
||||
exe := utils.FindExe(cmd[0])
|
||||
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`)
|
||||
|
||||
if bashrc := os.Getenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`); bashrc != `` {
|
||||
// prevent bash from source /etc/profile which is not under our control
|
||||
os.Unsetenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`)
|
||||
// prevent bash from sourcing /etc/profile which is not under our control
|
||||
env[`KITTY_BASH_INJECT`] += ` posix`
|
||||
env[`KITTY_BASH_POSIX_ENV`] = bashrc
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue