Skip to content

Commit 0ca416f

Browse files
committed
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
2 parents ce5cf6f + d87bd7c commit 0ca416f

File tree

4 files changed

+81
-63
lines changed

4 files changed

+81
-63
lines changed

t/t3300-funny-names.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ tree, index, and tree objects.
1111

1212
. ./test-lib.sh
1313

14+
HT=' '
15+
16+
echo 2>/dev/null > "Name with an${HT}HT"
17+
if ! test -f "Name with an${HT}HT"
18+
then
19+
# since FAT/NTFS does not allow tabs in filenames, skip this test
20+
skip_all='Your filesystem does not allow tabs in filenames'
21+
test_done
22+
fi
23+
1424
p0='no-funny'
1525
p1='tabs ," (dq) and spaces'
1626
p2='just space'
@@ -23,21 +33,9 @@ test_expect_success 'setup' '
2333
EOF
2434
2535
{ cat "$p0" >"$p1" || :; } &&
26-
{ echo "Foo Bar Baz" >"$p2" || :; } &&
27-
28-
if test -f "$p1" && cmp "$p0" "$p1"
29-
then
30-
test_set_prereq TABS_IN_FILENAMES
31-
fi
36+
{ echo "Foo Bar Baz" >"$p2" || :; }
3237
'
3338

34-
if ! test_have_prereq TABS_IN_FILENAMES
35-
then
36-
# since FAT/NTFS does not allow tabs in filenames, skip this test
37-
skip_all='Your filesystem does not allow tabs in filenames'
38-
test_done
39-
fi
40-
4139
test_expect_success 'setup: populate index and tree' '
4240
git update-index --add "$p0" "$p2" &&
4341
t0=$(git write-tree)

t/t3902-quoted.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ echo foo 2>/dev/null > "Name and an${HT}HT"
1616
if ! test -f "Name and an${HT}HT"
1717
then
1818
# FAT/NTFS does not allow tabs in filenames
19-
say 'Your filesystem does not allow tabs in filenames'
20-
else
21-
test_set_prereq TABS_IN_FILENAMES
19+
skip_all='Your filesystem does not allow tabs in filenames'
20+
test_done
2221
fi
2322

2423
for_each_name () {
@@ -31,7 +30,7 @@ for_each_name () {
3130
done
3231
}
3332

34-
test_expect_success TABS_IN_FILENAMES 'setup' '
33+
test_expect_success 'setup' '
3534
3635
mkdir "$FN" &&
3736
for_each_name "echo initial >\"\$name\"" &&
@@ -45,7 +44,7 @@ test_expect_success TABS_IN_FILENAMES 'setup' '
4544
4645
'
4746

48-
test_expect_success TABS_IN_FILENAMES 'setup expected files' '
47+
test_expect_success 'setup expected files' '
4948
cat >expect.quoted <<\EOF &&
5049
Name
5150
"Name and a\nLF"
@@ -75,74 +74,74 @@ With SP in it
7574
EOF
7675
'
7776

78-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-files' '
77+
test_expect_success 'check fully quoted output from ls-files' '
7978
8079
git ls-files >current && test_cmp expect.quoted current
8180
8281
'
8382

84-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-files' '
83+
test_expect_success 'check fully quoted output from diff-files' '
8584
8685
git diff --name-only >current &&
8786
test_cmp expect.quoted current
8887
8988
'
9089

91-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-index' '
90+
test_expect_success 'check fully quoted output from diff-index' '
9291
9392
git diff --name-only HEAD >current &&
9493
test_cmp expect.quoted current
9594
9695
'
9796

98-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-tree' '
97+
test_expect_success 'check fully quoted output from diff-tree' '
9998
10099
git diff --name-only HEAD^ HEAD >current &&
101100
test_cmp expect.quoted current
102101
103102
'
104103

105-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-tree' '
104+
test_expect_success 'check fully quoted output from ls-tree' '
106105
107106
git ls-tree --name-only -r HEAD >current &&
108107
test_cmp expect.quoted current
109108
110109
'
111110

112-
test_expect_success TABS_IN_FILENAMES 'setting core.quotepath' '
111+
test_expect_success 'setting core.quotepath' '
113112
114113
git config --bool core.quotepath false
115114
116115
'
117116

118-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-files' '
117+
test_expect_success 'check fully quoted output from ls-files' '
119118
120119
git ls-files >current && test_cmp expect.raw current
121120
122121
'
123122

124-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-files' '
123+
test_expect_success 'check fully quoted output from diff-files' '
125124
126125
git diff --name-only >current &&
127126
test_cmp expect.raw current
128127
129128
'
130129

131-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-index' '
130+
test_expect_success 'check fully quoted output from diff-index' '
132131
133132
git diff --name-only HEAD >current &&
134133
test_cmp expect.raw current
135134
136135
'
137136

138-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from diff-tree' '
137+
test_expect_success 'check fully quoted output from diff-tree' '
139138
140139
git diff --name-only HEAD^ HEAD >current &&
141140
test_cmp expect.raw current
142141
143142
'
144143

145-
test_expect_success TABS_IN_FILENAMES 'check fully quoted output from ls-tree' '
144+
test_expect_success 'check fully quoted output from ls-tree' '
146145
147146
git ls-tree --name-only -r HEAD >current &&
148147
test_cmp expect.raw current

t/t4016-diff-quote.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ P1='pathname with HT'
1313
P2='pathname with SP'
1414
P3='pathname
1515
with LF'
16-
if : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1"
17-
then
18-
test_set_prereq TABS_IN_FILENAMES
19-
else
20-
say 'Your filesystem does not allow tabs in filenames'
21-
fi
16+
echo 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || {
17+
skip_all='Your filesystem does not allow tabs in filenames'
18+
test_done
19+
}
2220

23-
test_expect_success TABS_IN_FILENAMES setup '
21+
test_expect_success setup '
2422
echo P0.0 >"$P0.0" &&
2523
echo P0.1 >"$P0.1" &&
2624
echo P0.2 >"$P0.2" &&
@@ -40,7 +38,7 @@ test_expect_success TABS_IN_FILENAMES setup '
4038
:
4139
'
4240

43-
test_expect_success TABS_IN_FILENAMES 'setup expected files' '
41+
test_expect_success 'setup expected files' '
4442
cat >expect <<\EOF
4543
rename pathname.1 => "Rpathname\twith HT.0" (100%)
4644
rename pathname.3 => "Rpathname\nwith LF.0" (100%)
@@ -52,12 +50,12 @@ cat >expect <<\EOF
5250
EOF
5351
'
5452

55-
test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
53+
test_expect_success 'git diff --summary -M HEAD' '
5654
git diff --summary -M HEAD >actual &&
5755
test_cmp expect actual
5856
'
5957

60-
test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
58+
test_expect_success 'git diff --numstat -M HEAD' '
6159
cat >expect <<-\EOF &&
6260
0 0 pathname.1 => "Rpathname\twith HT.0"
6361
0 0 pathname.3 => "Rpathname\nwith LF.0"
@@ -71,7 +69,7 @@ test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
7169
test_cmp expect actual
7270
'
7371

74-
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
72+
test_expect_success 'git diff --stat -M HEAD' '
7573
cat >expect <<-\EOF &&
7674
pathname.1 => "Rpathname\twith HT.0" | 0
7775
pathname.3 => "Rpathname\nwith LF.0" | 0

t/test-lib.sh

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ unset CDPATH
100100
unset GREP_OPTIONS
101101

102102
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
103-
1|2|true)
104-
echo "* warning: Some tests will not work if GIT_TRACE" \
105-
"is set as to trace on STDERR ! *"
106-
echo "* warning: Please set GIT_TRACE to something" \
107-
"other than 1, 2 or true ! *"
108-
;;
103+
1|2|true)
104+
echo "* warning: Some tests will not work if GIT_TRACE" \
105+
"is set as to trace on STDERR ! *"
106+
echo "* warning: Please set GIT_TRACE to something" \
107+
"other than 1, 2 or true ! *"
108+
;;
109109
esac
110110

111111
# Convenience
@@ -172,17 +172,23 @@ do
172172
esac
173173
done
174174

175-
if test -n "$color"; then
175+
if test -n "$color"
176+
then
176177
say_color () {
177178
(
178179
TERM=$ORIGINAL_TERM
179180
export TERM
180181
case "$1" in
181-
error) tput bold; tput setaf 1;; # bold red
182-
skip) tput bold; tput setaf 2;; # bold green
183-
pass) tput setaf 2;; # green
184-
info) tput setaf 3;; # brown
185-
*) test -n "$quiet" && return;;
182+
error)
183+
tput bold; tput setaf 1;; # bold red
184+
skip)
185+
tput bold; tput setaf 2;; # bold green
186+
pass)
187+
tput setaf 2;; # green
188+
info)
189+
tput setaf 3;; # brown
190+
*)
191+
test -n "$quiet" && return;;
186192
esac
187193
shift
188194
printf "%s" "$*"
@@ -298,7 +304,8 @@ test_run_ () {
298304
then
299305
test_eval_ "$test_cleanup"
300306
fi
301-
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
307+
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
308+
then
302309
echo ""
303310
fi
304311
return "$eval_ret"
@@ -346,7 +353,8 @@ test_at_end_hook_ () {
346353
test_done () {
347354
GIT_EXIT_OK=t
348355

349-
if test -z "$HARNESS_ACTIVE"; then
356+
if test -z "$HARNESS_ACTIVE"
357+
then
350358
test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
351359
mkdir -p "$test_results_dir"
352360
test_results_path="$test_results_dir/${0%.sh}-$$.counts"
@@ -375,10 +383,18 @@ test_done () {
375383
case "$test_failure" in
376384
0)
377385
# Maybe print SKIP message
386+
if test -n "$skip_all" && test $test_count -gt 0
387+
then
388+
error "Can't use skip_all after running some tests"
389+
fi
378390
[ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
379391

380-
if test $test_external_has_tap -eq 0; then
381-
say_color pass "# passed all $msg"
392+
if test $test_external_has_tap -eq 0
393+
then
394+
if test $test_count -gt 0
395+
then
396+
say_color pass "# passed all $msg"
397+
fi
382398
say "1..$test_count$skip_all"
383399
fi
384400

@@ -391,7 +407,8 @@ test_done () {
391407
exit 0 ;;
392408

393409
*)
394-
if test $test_external_has_tap -eq 0; then
410+
if test $test_external_has_tap -eq 0
411+
then
395412
say_color error "# failed $test_failure among $msg"
396413
say "1..$test_count"
397414
fi
@@ -471,22 +488,26 @@ then
471488
PATH=$GIT_VALGRIND/bin:$PATH
472489
GIT_EXEC_PATH=$GIT_VALGRIND/bin
473490
export GIT_VALGRIND
474-
elif test -n "$GIT_TEST_INSTALLED" ; then
491+
elif test -n "$GIT_TEST_INSTALLED"
492+
then
475493
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
476494
error "Cannot run git from $GIT_TEST_INSTALLED."
477495
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
478496
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
479497
else # normal case, use ../bin-wrappers only unless $with_dashes:
480498
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
481-
if ! test -x "$git_bin_dir/git" ; then
482-
if test -z "$with_dashes" ; then
499+
if ! test -x "$git_bin_dir/git"
500+
then
501+
if test -z "$with_dashes"
502+
then
483503
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
484504
fi
485505
with_dashes=t
486506
fi
487507
PATH="$git_bin_dir:$PATH"
488508
GIT_EXEC_PATH=$GIT_BUILD_DIR
489-
if test -n "$with_dashes" ; then
509+
if test -n "$with_dashes"
510+
then
490511
PATH="$GIT_BUILD_DIR:$PATH"
491512
fi
492513
fi
@@ -521,7 +542,8 @@ then
521542
}
522543
fi
523544

524-
if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then
545+
if ! test -x "$GIT_BUILD_DIR"/test-chmtime
546+
then
525547
echo >&2 'You need to build test-chmtime:'
526548
echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
527549
exit 1
@@ -544,7 +566,8 @@ rm -fr "$test" || {
544566
HOME="$TRASH_DIRECTORY"
545567
export HOME
546568

547-
if test -z "$TEST_NO_CREATE_REPO"; then
569+
if test -z "$TEST_NO_CREATE_REPO"
570+
then
548571
test_create_repo "$test"
549572
else
550573
mkdir -p "$test"

0 commit comments

Comments
 (0)