test-lib.sh: Fix some shell coding style violations
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramsay Jones committed
Sep 1, 2012 at 19:11 UTC
1c0cc7563b079e17f84cf93e5b735ec9fa4ad11a
1 file changed
+38
-22
t/test-lib.sh
+38
-22
@@ -100,12 +100,12 @@ unset CDPATH
100
unset GREP_OPTIONS
101
102
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
+ ;;
109
esac
110
111
# Convenience
@@ -172,17 +172,23 @@ do
172
esac
173
done
174
175
-if test -n "$color"; then
175
+if test -n "$color"
176
+then
177
say_color () {
178
(
179
TERM=$ORIGINAL_TERM
180
export TERM
181
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;;
192
esac
193
shift
194
printf "%s" "$*"
@@ -298,7 +304,8 @@ test_run_ () {
304
then
305
test_eval_ "$test_cleanup"
306
fi
301
- if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
307
+ if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
308
+ then
309
echo ""
310
fi
311
return "$eval_ret"
@@ -346,7 +353,8 @@ test_at_end_hook_ () {
353
test_done () {
354
GIT_EXIT_OK=t
355
349
- if test -z "$HARNESS_ACTIVE"; then
356
+ if test -z "$HARNESS_ACTIVE"
357
+ then
358
test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
359
mkdir -p "$test_results_dir"
360
test_results_path="$test_results_dir/${0%.sh}-$$.counts"
@@ -377,7 +385,8 @@ test_done () {
385
# Maybe print SKIP message
386
[ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
387
380
- if test $test_external_has_tap -eq 0; then
388
+ if test $test_external_has_tap -eq 0
389
+ then
390
say_color pass "# passed all $msg"
391
say "1..$test_count$skip_all"
392
fi
@@ -391,7 +400,8 @@ test_done () {
400
exit 0 ;;
401
402
*)
394
- if test $test_external_has_tap -eq 0; then
403
+ if test $test_external_has_tap -eq 0
404
+ then
405
say_color error "# failed $test_failure among $msg"
406
say "1..$test_count"
407
fi
@@ -471,22 +481,26 @@ then
481
PATH=$GIT_VALGRIND/bin:$PATH
482
GIT_EXEC_PATH=$GIT_VALGRIND/bin
483
export GIT_VALGRIND
474
-elif test -n "$GIT_TEST_INSTALLED" ; then
484
+elif test -n "$GIT_TEST_INSTALLED"
485
+then
486
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
487
error "Cannot run git from $GIT_TEST_INSTALLED."
488
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
489
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
490
else # normal case, use ../bin-wrappers only unless $with_dashes:
491
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
481
- if ! test -x "$git_bin_dir/git" ; then
482
- if test -z "$with_dashes" ; then
492
+ if ! test -x "$git_bin_dir/git"
493
+ then
494
+ if test -z "$with_dashes"
495
+ then
496
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
497
fi
498
with_dashes=t
499
fi
500
PATH="$git_bin_dir:$PATH"
501
GIT_EXEC_PATH=$GIT_BUILD_DIR
489
- if test -n "$with_dashes" ; then
502
+ if test -n "$with_dashes"
503
+ then
504
PATH="$GIT_BUILD_DIR:$PATH"
505
fi
506
fi
@@ -521,7 +535,8 @@ then
535
}
536
fi
537
524
-if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then
538
+if ! test -x "$GIT_BUILD_DIR"/test-chmtime
539
+then
540
echo >&2 'You need to build test-chmtime:'
541
echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
542
exit 1
@@ -544,7 +559,8 @@ rm -fr "$test" || {
559
HOME="$TRASH_DIRECTORY"
560
export HOME
561
547
-if test -z "$TEST_NO_CREATE_REPO"; then
562
+if test -z "$TEST_NO_CREATE_REPO"
563
+then
564
test_create_repo "$test"
565
else
566
mkdir -p "$test"