Skip to content

Commit

Permalink
Ensure ZSH-related tests succeed when TERM variable is set to linux (#…
Browse files Browse the repository at this point in the history
…497)

* Fix ZSH tests when TERM variable is set to linux

Running the test-suite with TERM=linux causes the ZSH related tests to
fail. Fixed by hardcoding TERM="" when running the ZSH tests.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>

* Also ensure zsh does not load global RC files when running test-suite

While bash only has a single option for disabling bashrc loading, ZSH
comes with two options: one for $HOME/.zshrc and one for the global
zshrc (typically located in /etc). Pass both options to avoid surprises.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>

---------

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot authored Aug 4, 2024
1 parent 368bc32 commit 042d091
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def run_command(self, command, **kwargs):

def _repl_sh(command, args, non_printable_insert):
os.environ["PS1"] = "$"
os.environ["TERM"] = ""
child = pexpect.spawn(command, args, echo=False, encoding="utf-8")
ps1 = PEXPECT_PROMPT[:5] + non_printable_insert + PEXPECT_PROMPT[5:]
ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + non_printable_insert + PEXPECT_CONTINUATION_PROMPT[5:]
Expand All @@ -79,7 +80,7 @@ def bash_repl(command="bash"):


def zsh_repl(command="zsh"):
sh = _repl_sh(command, ["--no-rcs", "-V"], non_printable_insert="%(!..)")
sh = _repl_sh(command, ["--no-rcs", "--no-globalrcs", "-V"], non_printable_insert="%(!..)")
# Require two tabs to print all options (some tests rely on this).
sh.run_command("setopt BASH_AUTO_LIST")
return sh
Expand Down

0 comments on commit 042d091

Please sign in to comment.