Merge branch 'rj/tap-fix'

* rj/tap-fix:
  test-lib.sh: Suppress the "passed all ..." message if no tests run
  test-lib.sh: Add check for invalid use of 'skip_all' facility
  test-lib.sh: Fix some shell coding style violations
  t4016-*.sh: Skip all tests rather than each test
  t3902-*.sh: Skip all tests rather than each test
  t3300-*.sh: Fix a TAP parse error
This commit is contained in:
Junio C Hamano 2012-09-14 11:53:45 -07:00
commit 0ca416f166
4 changed files with 81 additions and 63 deletions

View File

@ -11,6 +11,16 @@ tree, index, and tree objects.
. ./test-lib.sh . ./test-lib.sh
HT=' '
echo 2>/dev/null > "Name with an${HT}HT"
if ! test -f "Name with an${HT}HT"
then
# since FAT/NTFS does not allow tabs in filenames, skip this test
skip_all='Your filesystem does not allow tabs in filenames'
test_done
fi
p0='no-funny' p0='no-funny'
p1='tabs ," (dq) and spaces' p1='tabs ," (dq) and spaces'
p2='just space' p2='just space'
@ -23,21 +33,9 @@ test_expect_success 'setup' '
EOF EOF
{ cat "$p0" >"$p1" || :; } && { cat "$p0" >"$p1" || :; } &&
{ echo "Foo Bar Baz" >"$p2" || :; } && { echo "Foo Bar Baz" >"$p2" || :; }
if test -f "$p1" && cmp "$p0" "$p1"
then
test_set_prereq TABS_IN_FILENAMES
fi
' '
if ! test_have_prereq TABS_IN_FILENAMES
then
# since FAT/NTFS does not allow tabs in filenames, skip this test
skip_all='Your filesystem does not allow tabs in filenames'
test_done
fi
test_expect_success 'setup: populate index and tree' ' test_expect_success 'setup: populate index and tree' '
git update-index --add "$p0" "$p2" && git update-index --add "$p0" "$p2" &&
t0=$(git write-tree) t0=$(git write-tree)

View File

@ -16,9 +16,8 @@ echo foo 2>/dev/null > "Name and an${HT}HT"
if ! test -f "Name and an${HT}HT" if ! test -f "Name and an${HT}HT"
then then
# FAT/NTFS does not allow tabs in filenames # FAT/NTFS does not allow tabs in filenames
say 'Your filesystem does not allow tabs in filenames' skip_all='Your filesystem does not allow tabs in filenames'
else test_done
test_set_prereq TABS_IN_FILENAMES
fi fi
for_each_name () { for_each_name () {
@ -31,7 +30,7 @@ for_each_name () {
done done
} }
test_expect_success TABS_IN_FILENAMES 'setup' ' test_expect_success 'setup' '
mkdir "$FN" && mkdir "$FN" &&
for_each_name "echo initial >\"\$name\"" && for_each_name "echo initial >\"\$name\"" &&
@ -45,7 +44,7 @@ test_expect_success TABS_IN_FILENAMES 'setup' '
' '
test_expect_success TABS_IN_FILENAMES 'setup expected files' ' test_expect_success 'setup expected files' '
cat >expect.quoted <<\EOF && cat >expect.quoted <<\EOF &&
Name Name
"Name and a\nLF" "Name and a\nLF"
@ -75,74 +74,74 @@ With SP in it
EOF EOF
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-files' ' test_expect_success 'check fully quoted output from ls-files' '
git ls-files >current && test_cmp expect.quoted current git ls-files >current && test_cmp expect.quoted current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-files' ' test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current && git diff --name-only >current &&
test_cmp expect.quoted current test_cmp expect.quoted current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-index' ' test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current && git diff --name-only HEAD >current &&
test_cmp expect.quoted current test_cmp expect.quoted current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-tree' ' test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current && git diff --name-only HEAD^ HEAD >current &&
test_cmp expect.quoted current test_cmp expect.quoted current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-tree' ' test_expect_success 'check fully quoted output from ls-tree' '
git ls-tree --name-only -r HEAD >current && git ls-tree --name-only -r HEAD >current &&
test_cmp expect.quoted current test_cmp expect.quoted current
' '
test_expect_success TABS_IN_FILENAMES 'setting core.quotepath' ' test_expect_success 'setting core.quotepath' '
git config --bool core.quotepath false git config --bool core.quotepath false
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-files' ' test_expect_success 'check fully quoted output from ls-files' '
git ls-files >current && test_cmp expect.raw current git ls-files >current && test_cmp expect.raw current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-files' ' test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current && git diff --name-only >current &&
test_cmp expect.raw current test_cmp expect.raw current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-index' ' test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current && git diff --name-only HEAD >current &&
test_cmp expect.raw current test_cmp expect.raw current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-tree' ' test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current && git diff --name-only HEAD^ HEAD >current &&
test_cmp expect.raw current test_cmp expect.raw current
' '
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-tree' ' test_expect_success 'check fully quoted output from ls-tree' '
git ls-tree --name-only -r HEAD >current && git ls-tree --name-only -r HEAD >current &&
test_cmp expect.raw current test_cmp expect.raw current

View File

@ -13,14 +13,12 @@ P1='pathname with HT'
P2='pathname with SP' P2='pathname with SP'
P3='pathname P3='pathname
with LF' with LF'
if : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" echo 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || {
then skip_all='Your filesystem does not allow tabs in filenames'
test_set_prereq TABS_IN_FILENAMES test_done
else }
say 'Your filesystem does not allow tabs in filenames'
fi
test_expect_success TABS_IN_FILENAMES setup ' test_expect_success setup '
echo P0.0 >"$P0.0" && echo P0.0 >"$P0.0" &&
echo P0.1 >"$P0.1" && echo P0.1 >"$P0.1" &&
echo P0.2 >"$P0.2" && echo P0.2 >"$P0.2" &&
@ -40,7 +38,7 @@ test_expect_success TABS_IN_FILENAMES setup '
: :
' '
test_expect_success TABS_IN_FILENAMES 'setup expected files' ' test_expect_success 'setup expected files' '
cat >expect <<\EOF cat >expect <<\EOF
rename pathname.1 => "Rpathname\twith HT.0" (100%) rename pathname.1 => "Rpathname\twith HT.0" (100%)
rename pathname.3 => "Rpathname\nwith LF.0" (100%) rename pathname.3 => "Rpathname\nwith LF.0" (100%)
@ -52,12 +50,12 @@ cat >expect <<\EOF
EOF EOF
' '
test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' ' test_expect_success 'git diff --summary -M HEAD' '
git diff --summary -M HEAD >actual && git diff --summary -M HEAD >actual &&
test_cmp expect actual test_cmp expect actual
' '
test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' ' test_expect_success 'git diff --numstat -M HEAD' '
cat >expect <<-\EOF && cat >expect <<-\EOF &&
0 0 pathname.1 => "Rpathname\twith HT.0" 0 0 pathname.1 => "Rpathname\twith HT.0"
0 0 pathname.3 => "Rpathname\nwith LF.0" 0 0 pathname.3 => "Rpathname\nwith LF.0"
@ -71,7 +69,7 @@ test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
test_cmp expect actual test_cmp expect actual
' '
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' ' test_expect_success 'git diff --stat -M HEAD' '
cat >expect <<-\EOF && cat >expect <<-\EOF &&
pathname.1 => "Rpathname\twith HT.0" | 0 pathname.1 => "Rpathname\twith HT.0" | 0
pathname.3 => "Rpathname\nwith LF.0" | 0 pathname.3 => "Rpathname\nwith LF.0" | 0

View File

@ -100,12 +100,12 @@ unset CDPATH
unset GREP_OPTIONS unset GREP_OPTIONS
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
1|2|true) 1|2|true)
echo "* warning: Some tests will not work if GIT_TRACE" \ echo "* warning: Some tests will not work if GIT_TRACE" \
"is set as to trace on STDERR ! *" "is set as to trace on STDERR ! *"
echo "* warning: Please set GIT_TRACE to something" \ echo "* warning: Please set GIT_TRACE to something" \
"other than 1, 2 or true ! *" "other than 1, 2 or true ! *"
;; ;;
esac esac
# Convenience # Convenience
@ -172,17 +172,23 @@ do
esac esac
done done
if test -n "$color"; then if test -n "$color"
then
say_color () { say_color () {
( (
TERM=$ORIGINAL_TERM TERM=$ORIGINAL_TERM
export TERM export TERM
case "$1" in case "$1" in
error) tput bold; tput setaf 1;; # bold red error)
skip) tput bold; tput setaf 2;; # bold green tput bold; tput setaf 1;; # bold red
pass) tput setaf 2;; # green skip)
info) tput setaf 3;; # brown tput bold; tput setaf 2;; # bold green
*) test -n "$quiet" && return;; pass)
tput setaf 2;; # green
info)
tput setaf 3;; # brown
*)
test -n "$quiet" && return;;
esac esac
shift shift
printf "%s" "$*" printf "%s" "$*"
@ -298,7 +304,8 @@ test_run_ () {
then then
test_eval_ "$test_cleanup" test_eval_ "$test_cleanup"
fi fi
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
then
echo "" echo ""
fi fi
return "$eval_ret" return "$eval_ret"
@ -346,7 +353,8 @@ test_at_end_hook_ () {
test_done () { test_done () {
GIT_EXIT_OK=t GIT_EXIT_OK=t
if test -z "$HARNESS_ACTIVE"; then if test -z "$HARNESS_ACTIVE"
then
test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results" test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
mkdir -p "$test_results_dir" mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%.sh}-$$.counts" test_results_path="$test_results_dir/${0%.sh}-$$.counts"
@ -375,10 +383,18 @@ test_done () {
case "$test_failure" in case "$test_failure" in
0) 0)
# Maybe print SKIP message # Maybe print SKIP message
if test -n "$skip_all" && test $test_count -gt 0
then
error "Can't use skip_all after running some tests"
fi
[ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
if test $test_external_has_tap -eq 0; then if test $test_external_has_tap -eq 0
say_color pass "# passed all $msg" then
if test $test_count -gt 0
then
say_color pass "# passed all $msg"
fi
say "1..$test_count$skip_all" say "1..$test_count$skip_all"
fi fi
@ -391,7 +407,8 @@ test_done () {
exit 0 ;; exit 0 ;;
*) *)
if test $test_external_has_tap -eq 0; then if test $test_external_has_tap -eq 0
then
say_color error "# failed $test_failure among $msg" say_color error "# failed $test_failure among $msg"
say "1..$test_count" say "1..$test_count"
fi fi
@ -471,22 +488,26 @@ then
PATH=$GIT_VALGRIND/bin:$PATH PATH=$GIT_VALGRIND/bin:$PATH
GIT_EXEC_PATH=$GIT_VALGRIND/bin GIT_EXEC_PATH=$GIT_VALGRIND/bin
export GIT_VALGRIND export GIT_VALGRIND
elif test -n "$GIT_TEST_INSTALLED" ; then elif test -n "$GIT_TEST_INSTALLED"
then
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
error "Cannot run git from $GIT_TEST_INSTALLED." error "Cannot run git from $GIT_TEST_INSTALLED."
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH} GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
else # normal case, use ../bin-wrappers only unless $with_dashes: else # normal case, use ../bin-wrappers only unless $with_dashes:
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers" git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
if ! test -x "$git_bin_dir/git" ; then if ! test -x "$git_bin_dir/git"
if test -z "$with_dashes" ; then then
if test -z "$with_dashes"
then
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH" say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
fi fi
with_dashes=t with_dashes=t
fi fi
PATH="$git_bin_dir:$PATH" PATH="$git_bin_dir:$PATH"
GIT_EXEC_PATH=$GIT_BUILD_DIR GIT_EXEC_PATH=$GIT_BUILD_DIR
if test -n "$with_dashes" ; then if test -n "$with_dashes"
then
PATH="$GIT_BUILD_DIR:$PATH" PATH="$GIT_BUILD_DIR:$PATH"
fi fi
fi fi
@ -521,7 +542,8 @@ then
} }
fi fi
if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then if ! test -x "$GIT_BUILD_DIR"/test-chmtime
then
echo >&2 'You need to build test-chmtime:' echo >&2 'You need to build test-chmtime:'
echo >&2 'Run "make test-chmtime" in the source (toplevel) directory' echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
exit 1 exit 1
@ -544,7 +566,8 @@ rm -fr "$test" || {
HOME="$TRASH_DIRECTORY" HOME="$TRASH_DIRECTORY"
export HOME export HOME
if test -z "$TEST_NO_CREATE_REPO"; then if test -z "$TEST_NO_CREATE_REPO"
then
test_create_repo "$test" test_create_repo "$test"
else else
mkdir -p "$test" mkdir -p "$test"