test-lib-functions: adjust style to match CodingGuidelines
Prefer "test" over "[ ]" for conditionals. Prefer "$()" over backticks for command substitutions. Avoid control structures on a single line with semicolons. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Oct 15, 2014 at 01:35 UTC
76ee96a9b6f75e7d1c01e68ade72194179aa512d
1 file changed
+18
-12
t/test-lib-functions.sh
+18
-12
@@ -413,7 +413,7 @@ test_external () {
413
# test_run_, but keep its stdout on our stdout even in
414
# non-verbose mode.
415
"$@" 2>&4
416
- if [ "$?" = 0 ]
416
+ if test "$?" = 0
417
then
418
if test $test_external_has_tap -eq 0; then
419
test_ok_ "$descr"
@@ -440,11 +440,12 @@ test_external_without_stderr () {
440
tmp=${TMPDIR:-/tmp}
441
stderr="$tmp/git-external-stderr.$$.tmp"
442
test_external "$@" 4> "$stderr"
443
- [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
443
+ test -f "$stderr" || error "Internal error: $stderr disappeared."
444
descr="no stderr: $1"
445
shift
446
say >&3 "# expecting no stderr from previous command"
447
- if [ ! -s "$stderr" ]; then
447
+ if test ! -s "$stderr"
448
+ then
449
rm "$stderr"
450
451
if test $test_external_has_tap -eq 0; then
@@ -454,8 +455,9 @@ test_external_without_stderr () {
455
test_success=$(($test_success + 1))
456
fi
457
else
457
- if [ "$verbose" = t ]; then
458
- output=`echo; echo "# Stderr is:"; cat "$stderr"`
458
+ if test "$verbose" = t
459
+ then
460
+ output=$(echo; echo "# Stderr is:"; cat "$stderr")
461
else
462
output=
463
fi
@@ -474,7 +476,7 @@ test_external_without_stderr () {
476
# The commands test the existence or non-existence of $1. $2 can be
477
# given to provide a more precise diagnosis.
478
test_path_is_file () {
477
- if ! [ -f "$1" ]
479
+ if ! test -f "$1"
480
then
481
echo "File $1 doesn't exist. $*"
482
false
@@ -482,7 +484,7 @@ test_path_is_file () {
484
}
485
486
test_path_is_dir () {
485
- if ! [ -d "$1" ]
487
+ if ! test -d "$1"
488
then
489
echo "Directory $1 doesn't exist. $*"
490
false
@@ -490,11 +492,12 @@ test_path_is_dir () {
492
}
493
494
test_path_is_missing () {
493
- if [ -e "$1" ]
495
+ if test -e "$1"
496
then
497
echo "Path exists:"
498
ls -ld "$1"
497
- if [ $# -ge 1 ]; then
499
+ if test $# -ge 1
500
+ then
501
echo "$*"
502
fi
503
false
@@ -646,9 +649,12 @@ test_cmp_rev () {
649
# similar to GNU seq(1), but the latter might not be available
650
# everywhere (and does not do letters). It may be used like:
651
#
649
-# for i in `test_seq 100`; do
650
-# for j in `test_seq 10 20`; do
651
-# for k in `test_seq a z`; do
652
+# for i in $(test_seq 100)
653
+# do
654
+# for j in $(test_seq 10 20)
655
+# do
656
+# for k in $(test_seq a z)
657
+# do
658
# echo $i-$j-$k
659
# done
660
# done