From: Richard Hansen Date: Tue, 27 May 2014 07:41:00 GMT Subject: [PATCH 10/10] t9904: new __git_ps1 tests for Zsh Message-ID: <1401176460-31564-11-git-send-email-rhansen@bbn.com> In-Reply-To: <1401176460-31564-1-git-send-email-rhansen@bbn.com> These are the same tests as in t9903, but run in zsh instead of bash. Signed-off-by: Richard Hansen --- t/lib-zsh.sh | 30 ++++++++++++++++++++++++++++++ t/t9904-zsh-prompt.sh | 10 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 t/lib-zsh.sh create mode 100755 t/t9904-zsh-prompt.sh diff --git a/t/lib-zsh.sh b/t/lib-zsh.sh new file mode 100644 index 0000000..fa6fcd9 --- /dev/null +++ b/t/lib-zsh.sh @@ -0,0 +1,30 @@ +# Shell library sourced instead of ./test-lib.sh by tests that need to +# run under Zsh; primarily intended for tests of the git-prompt.sh +# script. + +if test -n "$ZSH_VERSION" && test -z "$POSIXLY_CORRECT"; then + true +elif command -v zsh >/dev/null 2>&1; then + unset POSIXLY_CORRECT + exec zsh "$0" "$@" +else + echo '1..0 #SKIP skipping Zsh-specific tests; zsh not available' + exit 0 +fi + +# ensure that we are in full-on Zsh mode +emulate -R zsh || exit 1 + +shellname=Zsh + +ps1_expansion_enable () { setopt PROMPT_SUBST; } +ps1_expansion_disable () { unsetopt PROMPT_SUBST; } +set_ps1_format_vars () { + percent='%%%%' + c_red='%%F{red}' + c_green='%%F{green}' + c_lblue='%%F{blue}' + c_clear='%%f' +} + +emulate sh -c '. ./test-lib.sh' diff --git a/t/t9904-zsh-prompt.sh b/t/t9904-zsh-prompt.sh new file mode 100755 index 0000000..a38a3fd --- /dev/null +++ b/t/t9904-zsh-prompt.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +test_description='test git-specific Zsh prompt functions' + +. ./lib-zsh.sh +. "$TEST_DIRECTORY"/lib-prompt-tests.sh + +run_prompt_tests + +test_done -- 1.9.3