Merge branch 'jn/test-cleanup-7006'

* jn/test-cleanup-7006:
  test: errors preparing for a test are not special
This commit is contained in:
Junio C Hamano
2011-12-22 11:27:24 -08:00

View File

@ -6,11 +6,6 @@ test_description='Test automatic use of a pager.'
. "$TEST_DIRECTORY"/lib-pager.sh . "$TEST_DIRECTORY"/lib-pager.sh
. "$TEST_DIRECTORY"/lib-terminal.sh . "$TEST_DIRECTORY"/lib-terminal.sh
cleanup_fail() {
echo >&2 cleanup failed
(exit 1)
}
test_expect_success 'setup' ' test_expect_success 'setup' '
sane_unset GIT_PAGER GIT_PAGER_IN_USE && sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
test_unconfig core.pager && test_unconfig core.pager &&
@ -22,9 +17,7 @@ test_expect_success 'setup' '
' '
test_expect_success TTY 'some commands use a pager' ' test_expect_success TTY 'some commands use a pager' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
test_terminal git log && test_terminal git log &&
test -e paginated.out test -e paginated.out
' '
@ -45,49 +38,37 @@ test_expect_failure TTY 'pager runs from subdir' '
' '
test_expect_success TTY 'some commands do not use a pager' ' test_expect_success TTY 'some commands do not use a pager' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
test_terminal git rev-list HEAD && test_terminal git rev-list HEAD &&
! test -e paginated.out ! test -e paginated.out
' '
test_expect_success 'no pager when stdout is a pipe' ' test_expect_success 'no pager when stdout is a pipe' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
git log | cat && git log | cat &&
! test -e paginated.out ! test -e paginated.out
' '
test_expect_success 'no pager when stdout is a regular file' ' test_expect_success 'no pager when stdout is a regular file' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
git log >file && git log >file &&
! test -e paginated.out ! test -e paginated.out
' '
test_expect_success TTY 'git --paginate rev-list uses a pager' ' test_expect_success TTY 'git --paginate rev-list uses a pager' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
test_terminal git --paginate rev-list HEAD && test_terminal git --paginate rev-list HEAD &&
test -e paginated.out test -e paginated.out
' '
test_expect_success 'no pager even with --paginate when stdout is a pipe' ' test_expect_success 'no pager even with --paginate when stdout is a pipe' '
rm -f file paginated.out || rm -f file paginated.out &&
cleanup_fail &&
git --paginate log | cat && git --paginate log | cat &&
! test -e paginated.out ! test -e paginated.out
' '
test_expect_success TTY 'no pager with --no-pager' ' test_expect_success TTY 'no pager with --no-pager' '
rm -f paginated.out || rm -f paginated.out &&
cleanup_fail &&
test_terminal git --no-pager log && test_terminal git --no-pager log &&
! test -e paginated.out ! test -e paginated.out
' '
@ -136,9 +117,7 @@ colorful() {
} }
test_expect_success 'tests can detect color' ' test_expect_success 'tests can detect color' '
rm -f colorful.log colorless.log || rm -f colorful.log colorless.log &&
cleanup_fail &&
git log --no-color >colorless.log && git log --no-color >colorless.log &&
git log --color >colorful.log && git log --color >colorful.log &&
! colorful colorless.log && ! colorful colorless.log &&
@ -147,18 +126,14 @@ test_expect_success 'tests can detect color' '
test_expect_success 'no color when stdout is a regular file' ' test_expect_success 'no color when stdout is a regular file' '
rm -f colorless.log && rm -f colorless.log &&
test_config color.ui auto || test_config color.ui auto &&
cleanup_fail &&
git log >colorless.log && git log >colorless.log &&
! colorful colorless.log ! colorful colorless.log
' '
test_expect_success TTY 'color when writing to a pager' ' test_expect_success TTY 'color when writing to a pager' '
rm -f paginated.out && rm -f paginated.out &&
test_config color.ui auto || test_config color.ui auto &&
cleanup_fail &&
( (
TERM=vt100 && TERM=vt100 &&
export TERM && export TERM &&
@ -181,9 +156,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
test_expect_success 'color when writing to a file intended for a pager' ' test_expect_success 'color when writing to a file intended for a pager' '
rm -f colorful.log && rm -f colorful.log &&
test_config color.ui auto || test_config color.ui auto &&
cleanup_fail &&
( (
TERM=vt100 && TERM=vt100 &&
GIT_PAGER_IN_USE=true && GIT_PAGER_IN_USE=true &&
@ -242,9 +215,7 @@ test_default_pager() {
$test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" " $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
sane_unset PAGER GIT_PAGER && sane_unset PAGER GIT_PAGER &&
test_unconfig core.pager && test_unconfig core.pager &&
rm -f default_pager_used || rm -f default_pager_used &&
cleanup_fail &&
cat >\$less <<-\EOF && cat >\$less <<-\EOF &&
#!/bin/sh #!/bin/sh
wc >default_pager_used wc >default_pager_used
@ -265,9 +236,7 @@ test_PAGER_overrides() {
$test_expectation TTY "$cmd - PAGER overrides default pager" " $test_expectation TTY "$cmd - PAGER overrides default pager" "
sane_unset GIT_PAGER && sane_unset GIT_PAGER &&
test_unconfig core.pager && test_unconfig core.pager &&
rm -f PAGER_used || rm -f PAGER_used &&
cleanup_fail &&
PAGER='wc >PAGER_used' && PAGER='wc >PAGER_used' &&
export PAGER && export PAGER &&
$full_command && $full_command &&
@ -292,9 +261,7 @@ test_core_pager() {
$test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" " $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" "
sane_unset GIT_PAGER && sane_unset GIT_PAGER &&
rm -f core.pager_used || rm -f core.pager_used &&
cleanup_fail &&
PAGER=wc && PAGER=wc &&
export PAGER && export PAGER &&
test_config core.pager 'wc >core.pager_used' && test_config core.pager 'wc >core.pager_used' &&
@ -321,9 +288,7 @@ test_pager_subdir_helper() {
$test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" " $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" "
sane_unset GIT_PAGER && sane_unset GIT_PAGER &&
rm -f core.pager_used && rm -f core.pager_used &&
rm -fr sub || rm -fr sub &&
cleanup_fail &&
PAGER=wc && PAGER=wc &&
stampname=\$(pwd)/core.pager_used && stampname=\$(pwd)/core.pager_used &&
export PAGER stampname && export PAGER stampname &&
@ -341,9 +306,7 @@ test_GIT_PAGER_overrides() {
parse_args "$@" parse_args "$@"
$test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " $test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" "
rm -f GIT_PAGER_used || rm -f GIT_PAGER_used &&
cleanup_fail &&
test_config core.pager wc && test_config core.pager wc &&
GIT_PAGER='wc >GIT_PAGER_used' && GIT_PAGER='wc >GIT_PAGER_used' &&
export GIT_PAGER && export GIT_PAGER &&
@ -356,9 +319,7 @@ test_doesnt_paginate() {
parse_args "$@" parse_args "$@"
$test_expectation TTY "no pager for '$cmd'" " $test_expectation TTY "no pager for '$cmd'" "
rm -f GIT_PAGER_used || rm -f GIT_PAGER_used &&
cleanup_fail &&
GIT_PAGER='wc >GIT_PAGER_used' && GIT_PAGER='wc >GIT_PAGER_used' &&
export GIT_PAGER && export GIT_PAGER &&
$full_command && $full_command &&