summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Eric Sunshine <sunshine@sunshineco.com>2021-12-09 00:11:07 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-12-13 10:29:48 -0800
commitc576868eaff8cc4c7fb5cf8b787756b16fde268b (patch)
tree4b109bff782f639dfeb0ff6e897edd48a19fa557
parenttests: fix broken &&-chains in compound statements (diff)
downloadtgif-c576868eaff8cc4c7fb5cf8b787756b16fde268b.tar.xz
tests: fix broken &&-chains in `$(...)` command substitutions
The top-level &&-chain checker built into t/test-lib.sh causes tests to magically exit with code 117 if the &&-chain is broken. However, it has the shortcoming that the magic does not work within `{...}` groups, `(...)` subshells, `$(...)` substitutions, or within bodies of compound statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed` partly fills in the gap by catching broken &&-chains in `(...)` subshells, but bugs can still lurk behind broken &&-chains in the other cases. Fix broken &&-chains in `$(...)` command substitutions in order to reduce the number of possible lurking bugs. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xcontrib/subtree/t/t7900-subtree.sh2
-rwxr-xr-xt/t0005-signals.sh2
-rwxr-xr-xt/t0060-path-utils.sh4
-rwxr-xr-xt/t1006-cat-file.sh10
-rwxr-xr-xt/t3600-rm.sh2
-rwxr-xr-xt/t7010-setup.sh2
6 files changed, 11 insertions, 11 deletions
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 4153b65321..1c1f76f04a 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -1445,7 +1445,7 @@ test_expect_success 'subtree descendant check' '
) &&
test_create_commit "$test_count" folder_subtree/0 &&
test_create_commit "$test_count" folder_subtree/b &&
- cherry=$(cd "$test_count"; git rev-parse HEAD) &&
+ cherry=$(cd "$test_count" && git rev-parse HEAD) &&
(
cd "$test_count" &&
git checkout branch
diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index a5ec6a0315..eba75a2490 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -48,7 +48,7 @@ test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
'
test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
- OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
+ OUT=$( ((trap "" PIPE && large_git; echo $? 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT"
'
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 34d1061f32..71a5d370cc 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -216,7 +216,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
mkdir second &&
ln -s ../first second/other &&
mkdir third &&
- dir="$(cd .git; pwd -P)" &&
+ dir="$(cd .git && pwd -P)" &&
dir2=third/../second/other/.git &&
test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
file="$dir"/index &&
@@ -224,7 +224,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
basename=blub &&
test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
ln -s ../first/file .git/syml &&
- sym="$(cd first; pwd -P)"/file &&
+ sym="$(cd first && pwd -P)"/file &&
test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
'
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 658628375c..67a3f64c2d 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -211,14 +211,14 @@ done
test_expect_success "--batch-check for a non-existent named object" '
test "foobar42 missing
foobar84 missing" = \
- "$( ( echo foobar42; echo_without_newline foobar84; ) | git cat-file --batch-check)"
+ "$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)"
'
test_expect_success "--batch-check for a non-existent hash" '
test "0000000000000000000000000000000000000042 missing
0000000000000000000000000000000000000084 missing" = \
- "$( ( echo 0000000000000000000000000000000000000042;
- echo_without_newline 0000000000000000000000000000000000000084; ) |
+ "$( ( echo 0000000000000000000000000000000000000042 &&
+ echo_without_newline 0000000000000000000000000000000000000084 ) |
git cat-file --batch-check)"
'
@@ -226,8 +226,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
test "$tag_sha1 tag $tag_size
$tag_content
0000000000000000000000000000000000000000 missing" = \
- "$( ( echo $tag_sha1;
- echo_without_newline 0000000000000000000000000000000000000000; ) |
+ "$( ( echo $tag_sha1 &&
+ echo_without_newline 0000000000000000000000000000000000000000 ) |
git cat-file --batch)"
'
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index bb9ef35dac..ed3952eb98 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -265,7 +265,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft (induce S
test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
choke_git_rm_setup &&
- OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
+ OUT=$( ((trap "" PIPE && git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" &&
test_path_is_missing .git/index.lock
'
diff --git a/t/t7010-setup.sh b/t/t7010-setup.sh
index 0335a9a158..520f96d09f 100755
--- a/t/t7010-setup.sh
+++ b/t/t7010-setup.sh
@@ -137,7 +137,7 @@ test_expect_success 'setup deeper work tree' '
test_expect_success 'add a directory outside the work tree' '(
cd tester &&
- d1="$(cd .. ; pwd)" &&
+ d1="$(cd .. && pwd)" &&
test_must_fail git add "$d1"
)'