Test choice of pager at several stages of repository setup. This way we can have some (admittedly uninteresting) examples in mind when considering future changes to the setup procedure. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- t/t7006-pager.sh | 151 ++++++++++++++++++++++++++++------------------------- 1 files changed, 80 insertions(+), 71 deletions(-) diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 4f804ed..403c260 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -131,78 +131,87 @@ then test_set_prereq SIMPLEPAGER fi -unset PAGER GIT_PAGER -git config --unset core.pager -rm -f default_pager_used -test_expect_success SIMPLEPAGER 'default pager is used by default' ' - cat > $less <<-EOF && - #!$SHELL_PATH - wc > default_pager_used - EOF - chmod +x $less && - PATH=.:$PATH test_terminal git log && - test -e default_pager_used -' - -unset GIT_PAGER -git config --unset core.pager -rm -f PAGER_used -test_expect_success TTY 'PAGER overrides default pager' ' - PAGER="wc > PAGER_used" && - export PAGER && - test_terminal git log && - test -e PAGER_used -' - -unset GIT_PAGER -rm -f core.pager_used -test_expect_success TTY 'core.pager overrides PAGER' ' - PAGER=wc && - export PAGER && - git config core.pager "wc > core.pager_used" && - test_terminal git log && - test -e core.pager_used -' - -unset GIT_PAGER -rm -f core.pager_used -rm -fr sub -test_expect_success TTY 'core.pager in subdir' ' - PAGER=wc && - stampname=$(pwd)/core.pager_used && - export PAGER stampname && - git config core.pager "wc > \"\$stampname\"" && - mkdir sub && - ( - cd sub && - test_terminal git log - ) && - test -e "$stampname" -' +test_pager_choice() { + if test $# = 1 + then + cmd=$1 + full_cmd="test_terminal $cmd" + else + cmd=$2 + full_cmd="test_must_fail test_terminal $cmd" + fi -unset GIT_PAGER -rm -f core.pager_used -rm -fr sub -test_expect_failure TTY 'core.pager in subdir with --paginate' ' - PAGER=wc && - stampname=$(pwd)/core.pager_used && - export PAGER stampname && - git config core.pager "wc > \"\$stampname\"" && - mkdir sub && - ( - cd sub && - test_terminal git --paginate log - ) && - test -e "$stampname" -' + case "$cmd" in + *-p*) + test_expect_expected=test_expect_failure + ;; + *) + test_expect_expected=test_expect_success + ;; + esac + + unset PAGER GIT_PAGER + git config --unset core.pager + rm -f default_pager_used + test_expect_success SIMPLEPAGER "$cmd - default pager is used by default" " + cat > $less <<-\EOF && + #!$SHELL_PATH + wc > default_pager_used + EOF + chmod +x $less && + PATH=.:\$PATH $full_cmd && + test -e default_pager_used + " + + unset GIT_PAGER + git config --unset core.pager + rm -f PAGER_used + test_expect_success TTY "$cmd - PAGER overrides default pager" " + PAGER='wc > PAGER_used' && + export PAGER && + $full_cmd && + test -e PAGER_used + " + + unset GIT_PAGER + rm -f core.pager_used + test_expect_success TTY "$cmd - core.pager overrides PAGER" " + PAGER=wc && + export PAGER && + git config core.pager 'wc > core.pager_used' && + $full_cmd && + test -e core.pager_used + " + + unset GIT_PAGER + rm -f core.pager_used + rm -fr sub + $test_expect_expected TTY "$cmd - core.pager in subdir" " + PAGER=wc && + stampname=\$(pwd)/core.pager_used && + export PAGER stampname && + git config core.pager 'wc > \"\$stampname\"' && + mkdir sub && + ( + cd sub && + $full_cmd + ) && + test -e \"\$stampname\" + " + + rm -f GIT_PAGER_used + test_expect_success TTY "$cmd - GIT_PAGER overrides core.pager" " + git config core.pager wc && + GIT_PAGER='wc > GIT_PAGER_used' && + export GIT_PAGER && + $full_cmd && + test -e GIT_PAGER_used + " +} -rm -f GIT_PAGER_used -test_expect_success TTY 'GIT_PAGER overrides core.pager' ' - git config core.pager wc && - GIT_PAGER="wc > GIT_PAGER_used" && - export GIT_PAGER && - test_terminal git log && - test -e GIT_PAGER_used -' +test_pager_choice 'git log' +test_pager_choice 'git -p log' +test_pager_choice test_must_fail 'git -p' +test_pager_choice test_must_fail 'git -p nonsense' test_done -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html