1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 21:07:52 +01:00

chainlint.pl: add test_expect_success call to test snippets

The chainlint tests are a series of individual files, each holding a
test body. The "make check-chainlint" target assembles them into a
single file, adding a "test_expect_success" function call around each.
Let's instead include that function call in the files themselves. This
is a little more boilerplate, but has several advantages:

  1. You can now run chainlint manually on snippets with just "perl
     chainlint.perl chainlint/foo.test". This can make developing and
     debugging a little easier.

  2. Many of the tests implicitly relied on the syntax of the lines
     added by the Makefile (in particular the use of single-quotes).
     This assumption is much easier to see when the single-quotes are
     alongside the test body.

  3. We had no way to test how the chainlint program handled
     various test_expect_success lines themselves. Now we'll be able to
     check variations.

The change to the .test files was done mechanically, using the same
test names they would have been assigned by the Makefile (this is
important to match the expected output). The Makefile has the minimal
change to drop the extra lines; there are more cleanups possible but a
future patch in this series will rewrite this substantially anyway.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2024-07-10 04:34:48 -04:00 committed by Junio C Hamano
parent 790a17fb19
commit a5e450144d
73 changed files with 145 additions and 3 deletions

View file

@ -109,9 +109,7 @@ clean-chainlint:
check-chainlint: check-chainlint:
@mkdir -p '$(CHAINLINTTMP_SQ)' && \ @mkdir -p '$(CHAINLINTTMP_SQ)' && \
for i in $(CHAINLINTTESTS); do \ for i in $(CHAINLINTTESTS); do \
echo "test_expect_success '$$i' '" && \ sed -e '/^# LINT: /d' chainlint/$$i.test; \
sed -e '/^# LINT: /d' chainlint/$$i.test && \
echo "'"; \
done >'$(CHAINLINTTMP_SQ)'/tests && \ done >'$(CHAINLINTTMP_SQ)'/tests && \
{ \ { \
echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \ echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \

View file

@ -1,3 +1,4 @@
test_expect_success 'arithmetic-expansion' '
( (
foo && foo &&
# LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")" # LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")"
@ -9,3 +10,4 @@
bar=$((42 + 1)) bar=$((42 + 1))
baz baz
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'bash-array' '
( (
foo && foo &&
# LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")" # LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")"
@ -10,3 +11,4 @@
bar=${#bar[@]} && bar=${#bar[@]} &&
baz baz
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'blank-line-before-esac' '
# LINT: blank line before "esac" # LINT: blank line before "esac"
test_done () { test_done () {
case "$test_failure" in case "$test_failure" in
@ -17,3 +18,4 @@ test_done () {
esac esac
} }
'

View file

@ -1,3 +1,4 @@
test_expect_success 'blank-line' '
( (
nothing && nothing &&
@ -8,3 +9,4 @@
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'block-comment' '
( (
{ {
# show a # show a
@ -6,3 +7,4 @@
echo b echo b
} }
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'block' '
( (
# LINT: missing "&&" after first "echo" # LINT: missing "&&" after first "echo"
foo && foo &&
@ -25,3 +26,4 @@
echo "done" echo "done"
} && } &&
finis finis
'

View file

@ -1,3 +1,4 @@
test_expect_success 'broken-chain' '
( (
foo && foo &&
# LINT: missing "&&" from "bar" # LINT: missing "&&" from "bar"
@ -6,3 +7,4 @@
# LINT: final statement before closing ")" legitimately lacks "&&" # LINT: final statement before closing ")" legitimately lacks "&&"
wop wop
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'case-comment' '
( (
case "$x" in case "$x" in
# found foo # found foo
@ -9,3 +10,4 @@
;; ;;
esac esac
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'case' '
( (
# LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")" # LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
case "$x" in case "$x" in
@ -21,3 +22,4 @@
case "$y" in 2) false;; esac case "$y" in 2) false;; esac
foobar foobar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chain-break-background' '
JGIT_DAEMON_PID= && JGIT_DAEMON_PID= &&
git init --bare empty.git && git init --bare empty.git &&
>empty.git/git-daemon-export-ok && >empty.git/git-daemon-export-ok &&
@ -8,3 +9,4 @@ mkfifo jgit_daemon_output &&
JGIT_DAEMON_PID=$! JGIT_DAEMON_PID=$!
} && } &&
test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chain-break-continue' '
git ls-tree --name-only -r refs/notes/many_notes | git ls-tree --name-only -r refs/notes/many_notes |
while read path while read path
do do
@ -11,3 +12,4 @@ do
return 1 return 1
fi fi
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chain-break-false' '
# LINT: broken &&-chain okay if explicit "false" signals failure # LINT: broken &&-chain okay if explicit "false" signals failure
if condition not satisified if condition not satisified
then then
@ -8,3 +9,4 @@ else
echo it went okay echo it went okay
congratulate user congratulate user
fi fi
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chain-break-return-exit' '
case "$(git ls-files)" in case "$(git ls-files)" in
one) echo pass one ;; one) echo pass one ;;
# LINT: broken &&-chain okay if explicit "return 1" signals failuire # LINT: broken &&-chain okay if explicit "return 1" signals failuire
@ -21,3 +22,4 @@ for i in 1 2 3 4 ; do
git checkout main -b $i || return $? git checkout main -b $i || return $?
test_commit $i $i $i tag$i || return $? test_commit $i $i $i tag$i || return $?
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chain-break-status' '
# LINT: broken &&-chain okay if next command handles "$?" explicitly # LINT: broken &&-chain okay if next command handles "$?" explicitly
OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) && OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" && test_match_signal 13 "$OUT" &&
@ -9,3 +10,4 @@ test_match_signal 13 "$OUT" &&
test "$ret" = 3 test "$ret" = 3
} && } &&
test_cmp expect actual test_cmp expect actual
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chained-block' '
# LINT: start of block chained to preceding command # LINT: start of block chained to preceding command
echo nobody home && { echo nobody home && {
test the doohicky test the doohicky
@ -9,3 +10,4 @@ GIT_EXTERNAL_DIFF=echo git diff | {
read path oldfile oldhex oldmode newfile newhex newmode && read path oldfile oldhex oldmode newfile newhex newmode &&
test "z$oh" = "z$oldhex" test "z$oh" = "z$oldhex"
} }
'

View file

@ -1,3 +1,4 @@
test_expect_success 'chained-subshell' '
# LINT: start of subshell chained to preceding command # LINT: start of subshell chained to preceding command
mkdir sub && ( mkdir sub && (
cd sub && cd sub &&
@ -11,3 +12,4 @@ test -f $s1
test $(cat $s2) = tree2path1 && test $(cat $s2) = tree2path1 &&
# LINT: closing subshell ")" correctly detected on same line as "$(...)" # LINT: closing subshell ")" correctly detected on same line as "$(...)"
test $(cat $s3) = tree3path1) test $(cat $s3) = tree3path1)
'

View file

@ -1,3 +1,5 @@
test_expect_success 'close-nested-and-parent-together' '
(cd foo && (cd foo &&
(bar && (bar &&
baz)) baz))
'

View file

@ -1,3 +1,4 @@
test_expect_success 'close-subshell' '
# LINT: closing ")" with various decorations ("&&", ">", "|", etc.) # LINT: closing ")" with various decorations ("&&", ">", "|", etc.)
( (
foo foo
@ -25,3 +26,4 @@ fuzzle &&
( (
yop yop
) )
'

View file

@ -1,3 +1,5 @@
test_expect_success 'command-substitution-subsubshell' '
# LINT: subshell nested in subshell nested in command substitution # LINT: subshell nested in subshell nested in command substitution
OUT=$( ((large_git 1>&3) | :) 3>&1 ) && OUT=$( ((large_git 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" test_match_signal 13 "$OUT"
'

View file

@ -1,3 +1,4 @@
test_expect_success 'command-substitution' '
( (
foo && foo &&
# LINT: closing ")" of $(...) not misinterpreted as subshell-closing ")" # LINT: closing ")" of $(...) not misinterpreted as subshell-closing ")"
@ -9,3 +10,4 @@
bar=$(gobble blocks) bar=$(gobble blocks)
baz baz
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'comment' '
( (
# LINT: swallow comment lines # LINT: swallow comment lines
# comment 1 # comment 1
@ -9,3 +10,4 @@
# comment 3 # comment 3
# comment 4 # comment 4
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'complex-if-in-cuddled-loop' '
# LINT: "for" loop cuddled with "(" and ")" and nested "if" with complex # LINT: "for" loop cuddled with "(" and ")" and nested "if" with complex
# LINT: multi-line condition; indented with spaces, not tabs # LINT: multi-line condition; indented with spaces, not tabs
(for i in a b c; do (for i in a b c; do
@ -9,3 +10,4 @@
fi fi
done) && done) &&
test ! -f file test ! -f file
'

View file

@ -1,3 +1,4 @@
test_expect_success 'cuddled-if-then-else' '
# LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs # LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs
(if test -z ""; then (if test -z ""; then
echo empty echo empty
@ -5,3 +6,4 @@
echo bizzy echo bizzy
fi) && fi) &&
echo foobar echo foobar
'

View file

@ -1,3 +1,4 @@
test_expect_success 'cuddled-loop' '
# LINT: "while" loop cuddled with "(" and ")", with embedded (allowed) # LINT: "while" loop cuddled with "(" and ")", with embedded (allowed)
# LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed # LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
# LINT: loop; indented with spaces, not tabs # LINT: loop; indented with spaces, not tabs
@ -5,3 +6,4 @@
do foobar bop || exit 1 do foobar bop || exit 1
done <file ) && done <file ) &&
outside subshell outside subshell
'

View file

@ -1,3 +1,4 @@
test_expect_success 'cuddled' '
# LINT: first subshell statement cuddled with opening "(" # LINT: first subshell statement cuddled with opening "("
(cd foo && (cd foo &&
bar bar
@ -20,3 +21,4 @@
# LINT: same with missing "&&" # LINT: same with missing "&&"
(cd foo (cd foo
bar) bar)
'

View file

@ -1,3 +1,4 @@
test_expect_success 'double-here-doc' '
run_sub_test_lib_test_err run-inv-range-start \ run_sub_test_lib_test_err run-inv-range-start \
"--run invalid range start" \ "--run invalid range start" \
--run="a-5" <<-\EOF && --run="a-5" <<-\EOF &&
@ -10,3 +11,4 @@ check_sub_test_lib_test_err run-inv-range-start \
EOF_OUT EOF_OUT
> error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ} > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ}
EOF_ERR EOF_ERR
'

View file

@ -1,3 +1,4 @@
test_expect_success 'dqstring-line-splice' '
# LINT: line-splice within DQ-string # LINT: line-splice within DQ-string
'" '"
echo 'fatal: reword option of --fixup is mutually exclusive with'\ echo 'fatal: reword option of --fixup is mutually exclusive with'\
@ -5,3 +6,4 @@ echo 'fatal: reword option of --fixup is mutually exclusive with'\
test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual && test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual &&
test_cmp expect actual test_cmp expect actual
"' "'
'

View file

@ -1,3 +1,4 @@
test_expect_success 'dqstring-no-interpolate' '
# LINT: regex dollar-sign eol anchor in double-quoted string not special # LINT: regex dollar-sign eol anchor in double-quoted string not special
grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out && grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out &&
@ -13,3 +14,4 @@ grep "^\\.git\$" output.txt &&
cut -d ' ' -f 2 <output | sort >actual && cut -d ' ' -f 2 <output | sort >actual &&
test_cmp expect actual test_cmp expect actual
"' "'
'

View file

@ -1,5 +1,7 @@
test_expect_success 'empty-here-doc' '
git ls-tree $tree path >current && git ls-tree $tree path >current &&
# LINT: empty here-doc # LINT: empty here-doc
cat >expected <<\EOF && cat >expected <<\EOF &&
EOF EOF
test_output test_output
'

View file

@ -1,3 +1,4 @@
test_expect_success 'exclamation' '
# LINT: "! word" is two tokens # LINT: "! word" is two tokens
if ! condition; then echo nope; else yep; fi && if ! condition; then echo nope; else yep; fi &&
# LINT: "!word" is single token, not two tokens "!" and "word" # LINT: "!word" is single token, not two tokens "!" and "word"
@ -6,3 +7,4 @@ test_prerequisite !MINGW &&
mail uucp!address && mail uucp!address &&
# LINT: "!word!" is single token, not three tokens "!", "word", and "!" # LINT: "!word!" is single token, not three tokens "!", "word", and "!"
echo !whatever! echo !whatever!
'

View file

@ -1,3 +1,4 @@
test_expect_success 'exit-loop' '
( (
for i in a b c for i in a b c
do do
@ -25,3 +26,4 @@
i=$(($i + 1)) i=$(($i + 1))
done done
) )
'

View file

@ -1,6 +1,8 @@
test_expect_success 'exit-subshell' '
( (
# LINT: "|| exit {n}" valid subshell escape without hurting &&-chain # LINT: "|| exit {n}" valid subshell escape without hurting &&-chain
foo || exit 1 foo || exit 1
bar && bar &&
baz baz
) )
'

View file

@ -1,6 +1,8 @@
test_expect_success 'for-loop-abbreviated' '
# LINT: for-loop lacking optional "in [word...]" before "do" # LINT: for-loop lacking optional "in [word...]" before "do"
for it for it
do do
path=$(expr "$it" : '\([^:]*\)') && path=$(expr "$it" : '\([^:]*\)') &&
git update-index --add "$path" || exit git update-index --add "$path" || exit
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'for-loop' '
( (
# LINT: "for", "do", "done" do not need "&&" # LINT: "for", "do", "done" do not need "&&"
for i in a b c for i in a b c
@ -17,3 +18,4 @@
cat $i cat $i
done done
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'function' '
# LINT: "()" in function definition not mistaken for subshell # LINT: "()" in function definition not mistaken for subshell
sha1_file() { sha1_file() {
echo "$*" | sed "s#..#.git/objects/&/#" echo "$*" | sed "s#..#.git/objects/&/#"
@ -11,3 +12,4 @@ remove_object() {
} }
sha1_file arg && remove_object arg sha1_file arg && remove_object arg
'

View file

@ -1,5 +1,7 @@
test_expect_success 'here-doc-close-subshell' '
( (
# LINT: line contains here-doc and closes nested subshell # LINT: line contains here-doc and closes nested subshell
cat <<-\INPUT) cat <<-\INPUT)
fizz fizz
INPUT INPUT
'

View file

@ -1,3 +1,4 @@
test_expect_success 'here-doc-indent-operator' '
# LINT: whitespace between operator "<<-" and tag legal # LINT: whitespace between operator "<<-" and tag legal
cat >expect <<- EOF && cat >expect <<- EOF &&
header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
@ -11,3 +12,4 @@ this is not indented
-EOF -EOF
cleanup cleanup
'

View file

@ -1,3 +1,4 @@
test_expect_success 'here-doc-multi-line-command-subst' '
( (
# LINT: line contains here-doc and opens multi-line $(...) # LINT: line contains here-doc and opens multi-line $(...)
x=$(bobble <<-\END && x=$(bobble <<-\END &&
@ -7,3 +8,4 @@
wiffle) wiffle)
echo $x echo $x
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'here-doc-multi-line-string' '
( (
# LINT: line contains here-doc and opens multi-line string # LINT: line contains here-doc and opens multi-line string
cat <<-\TXT && echo "multi-line cat <<-\TXT && echo "multi-line
@ -6,3 +7,4 @@
TXT TXT
bap bap
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'here-doc' '
# LINT: stitch together incomplete \-ending lines # LINT: stitch together incomplete \-ending lines
# LINT: swallow here-doc to avoid false positives in content # LINT: swallow here-doc to avoid false positives in content
boodle wobba \ boodle wobba \
@ -28,3 +29,4 @@ morticia
wednesday wednesday
pugsly pugsly
EOF EOF
'

View file

@ -1,3 +1,4 @@
test_expect_success 'if-condition-split' '
# LINT: "if" condition split across multiple lines at "&&" or "||" # LINT: "if" condition split across multiple lines at "&&" or "||"
if bob && if bob &&
marcia || marcia ||
@ -6,3 +7,4 @@ then
echo "nomads" echo "nomads"
echo "for sure" echo "for sure"
fi fi
'

View file

@ -1,3 +1,4 @@
test_expect_success 'if-in-loop' '
( (
for i in a b c for i in a b c
do do
@ -13,3 +14,4 @@
done done
bar bar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'if-then-else' '
( (
# LINT: "if", "then", "elif", "else", "fi" do not need "&&" # LINT: "if", "then", "elif", "else", "fi" do not need "&&"
if test -n "" if test -n ""
@ -27,3 +28,4 @@
echo empty echo empty
fi fi
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'incomplete-line' '
# LINT: stitch together all incomplete \-ending lines # LINT: stitch together all incomplete \-ending lines
line 1 \ line 1 \
line 2 \ line 2 \
@ -10,3 +11,4 @@ line 4 &&
line 7 \ line 7 \
line 8 line 8
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'inline-comment' '
( (
# LINT: swallow inline comment (leaving command intact) # LINT: swallow inline comment (leaving command intact)
foobar && # comment 1 foobar && # comment 1
@ -10,3 +11,4 @@
# LINT: "#" in string in cuddled subshell not misinterpreted as comment # LINT: "#" in string in cuddled subshell not misinterpreted as comment
(cd foo && (cd foo &&
flibble "not a # comment") flibble "not a # comment")
'

View file

@ -1,3 +1,4 @@
test_expect_success 'loop-detect-failure' '
git init r1 && git init r1 &&
# LINT: loop handles failure explicitly with "|| return 1" # LINT: loop handles failure explicitly with "|| return 1"
for n in 1 2 3 4 5 for n in 1 2 3 4 5
@ -15,3 +16,4 @@ do
git -C r2 add large.$n && git -C r2 add large.$n &&
git -C r2 commit -m "$n" git -C r2 commit -m "$n"
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'loop-detect-status' '
# LINT: "$?" handled explicitly within loop body # LINT: "$?" handled explicitly within loop body
(while test $i -le $blobcount (while test $i -le $blobcount
do do
@ -17,3 +18,4 @@
cat commit) | cat commit) |
git fast-import --big-file-threshold=2 && git fast-import --big-file-threshold=2 &&
test ! -f exit-status test ! -f exit-status
'

View file

@ -1,3 +1,4 @@
test_expect_success 'loop-in-if' '
( (
if true if true
then then
@ -13,3 +14,4 @@
fi fi
bar bar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'loop-upstream-pipe' '
( (
git rev-list --objects --no-object-names base..loose | git rev-list --objects --no-object-names base..loose |
while read oid while read oid
@ -9,3 +10,4 @@
done | done |
sort -k1 sort -k1
) >expect && ) >expect &&
'

View file

@ -1,3 +1,4 @@
test_expect_success 'multi-line-nested-command-substitution' '
( (
foo && foo &&
x=$( x=$(
@ -16,3 +17,4 @@ sort &&
fip) && fip) &&
echo fail echo fail
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'multi-line-string' '
( (
x="line 1 x="line 1
line 2 line 2
@ -13,3 +14,4 @@
ghi" && ghi" &&
barfoo barfoo
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'negated-one-liner' '
# LINT: top-level one-liner subshell # LINT: top-level one-liner subshell
! (foo && bar) && ! (foo && bar) &&
! (foo && bar) >baz && ! (foo && bar) >baz &&
@ -5,3 +6,4 @@
# LINT: top-level one-liner subshell missing internal "&&" # LINT: top-level one-liner subshell missing internal "&&"
! (foo; bar) && ! (foo; bar) &&
! (foo; bar) >baz ! (foo; bar) >baz
'

View file

@ -1,3 +1,4 @@
test_expect_success 'nested-cuddled-subshell' '
( (
# LINT: opening "(" cuddled with first nested subshell statement # LINT: opening "(" cuddled with first nested subshell statement
(cd foo && (cd foo &&
@ -29,3 +30,4 @@
foobar foobar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'nested-here-doc' '
# LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc # LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc
cat <<ARBITRARY >foop && cat <<ARBITRARY >foop &&
naddle naddle
@ -31,3 +32,4 @@ ARBITRARY
foobar foobar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'nested-loop-detect-failure' '
# LINT: neither loop handles failure explicitly with "|| return 1" # LINT: neither loop handles failure explicitly with "|| return 1"
for i in 0 1 2 3 4 5 6 7 8 9; for i in 0 1 2 3 4 5 6 7 8 9;
do do
@ -33,3 +34,4 @@ do
echo "$i$j" >"path$i$j" || return 1 echo "$i$j" >"path$i$j" || return 1
done || return 1 done || return 1
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'nested-subshell-comment' '
( (
foo && foo &&
( (
@ -11,3 +12,4 @@
) )
fuzzy fuzzy
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'nested-subshell' '
( (
cd foo && cd foo &&
( (
@ -11,3 +12,4 @@
echo b echo b
) >file ) >file
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'not-heredoc' '
# LINT: "<< ours" inside string is not here-doc # LINT: "<< ours" inside string is not here-doc
echo "<<<<<<< ours" && echo "<<<<<<< ours" &&
echo ourside && echo ourside &&
@ -14,3 +15,4 @@ echo ">>>>>>> theirs" &&
echo ">>>>>>> theirs" echo ">>>>>>> theirs"
poodle poodle
) >merged ) >merged
'

View file

@ -1,3 +1,4 @@
test_expect_success 'one-liner-for-loop' '
git init dir-rename-and-content && git init dir-rename-and-content &&
( (
cd dir-rename-and-content && cd dir-rename-and-content &&
@ -8,3 +9,4 @@ git init dir-rename-and-content &&
git add foo olddir && git add foo olddir &&
git commit -m "original" && git commit -m "original" &&
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'one-liner' '
# LINT: top-level one-liner subshell # LINT: top-level one-liner subshell
(foo && bar) && (foo && bar) &&
(foo && bar) | (foo && bar) |
@ -10,3 +11,4 @@
# LINT: ";" in string not misinterpreted as broken &&-chain # LINT: ";" in string not misinterpreted as broken &&-chain
(foo "bar; baz") (foo "bar; baz")
'

View file

@ -1,5 +1,7 @@
test_expect_success 'p4-filespec' '
( (
# LINT: Perforce revspec in filespec not misinterpreted as in-line comment # LINT: Perforce revspec in filespec not misinterpreted as in-line comment
p4 print -1 //depot/fiddle#42 >file && p4 print -1 //depot/fiddle#42 >file &&
foobar foobar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'pipe' '
( (
# LINT: no "&&" needed on line ending with "|" # LINT: no "&&" needed on line ending with "|"
foo | foo |
@ -10,3 +11,4 @@
sunder sunder
) )
'

View file

@ -1,6 +1,8 @@
test_expect_success 'return-loop' '
while test $i -lt $((num - 5)) while test $i -lt $((num - 5))
do do
# LINT: "|| return {n}" valid loop escape outside subshell; no "&&" needed # LINT: "|| return {n}" valid loop escape outside subshell; no "&&" needed
git notes add -m "notes for commit$i" HEAD~$i || return 1 git notes add -m "notes for commit$i" HEAD~$i || return 1
i=$((i + 1)) i=$((i + 1))
done done
'

View file

@ -1,3 +1,4 @@
test_expect_success 'semicolon' '
( (
# LINT: missing internal "&&" and ending "&&" # LINT: missing internal "&&" and ending "&&"
cat foo ; echo bar cat foo ; echo bar
@ -23,3 +24,4 @@
# LINT: semicolon unnecessary but legitimate # LINT: semicolon unnecessary but legitimate
echo; echo;
done) done)
'

View file

@ -1,5 +1,7 @@
test_expect_success 'sqstring-in-sqstring' '
# LINT: SQ-string Perl code fragment within SQ-string # LINT: SQ-string Perl code fragment within SQ-string
perl -e '\'' perl -e '\''
defined($_ = -s $_) or die for @ARGV; defined($_ = -s $_) or die for @ARGV;
exit 1 if $ARGV[0] <= $ARGV[1]; exit 1 if $ARGV[0] <= $ARGV[1];
'\'' test-2-$packname_2.pack test-3-$packname_3.pack '\'' test-2-$packname_2.pack test-3-$packname_3.pack
'

View file

@ -1,3 +1,4 @@
test_expect_success 'subshell-here-doc' '
( (
# LINT: stitch together incomplete \-ending lines # LINT: stitch together incomplete \-ending lines
# LINT: swallow here-doc to avoid false positives in content # LINT: swallow here-doc to avoid false positives in content
@ -33,3 +34,4 @@ EOF
ARBITRARY3 ARBITRARY3
meep meep
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'subshell-one-liner' '
( (
# LINT: nested one-liner subshell # LINT: nested one-liner subshell
(foo && bar) && (foo && bar) &&
@ -22,3 +23,4 @@
foobar foobar
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 't7900-subtree' '
( (
chks="sub1 chks="sub1
sub2 sub2
@ -20,3 +21,4 @@ TXT
check_equal "$subfiles" "$chkms check_equal "$subfiles" "$chkms
$chks" $chks"
) )
'

View file

@ -1,3 +1,4 @@
test_expect_success 'token-pasting' '
# LINT: single token; composite of multiple strings # LINT: single token; composite of multiple strings
git config filter.rot13.smudge ./rot13.sh && git config filter.rot13.smudge ./rot13.sh &&
git config filter.rot13.clean ./rot13.sh && git config filter.rot13.clean ./rot13.sh &&
@ -30,3 +31,4 @@ downstream_url_for_sed=$(
# LINT: exit/enter string context; "&" inside string not command terminator # LINT: exit/enter string context; "&" inside string not command terminator
sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\'' sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
) )
'

View file

@ -1,4 +1,6 @@
test_expect_success 'unclosed-here-doc-indent' '
command_which_is_run && command_which_is_run &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
we forget to end the here-doc we forget to end the here-doc
command_which_is_gobbled command_which_is_gobbled
'

View file

@ -1,3 +1,4 @@
test_expect_success 'unclosed-here-doc' '
command_which_is_run && command_which_is_run &&
cat >expect <<\EOF && cat >expect <<\EOF &&
we try to end the here-doc below, we try to end the here-doc below,
@ -5,3 +6,4 @@ cat >expect <<\EOF &&
since the operator is not "<<-". since the operator is not "<<-".
EOF EOF
command_which_is_gobbled command_which_is_gobbled
'

View file

@ -1,3 +1,4 @@
test_expect_success 'while-loop' '
( (
# LINT: "while", "do", "done" do not need "&&" # LINT: "while", "do", "done" do not need "&&"
while true while true
@ -17,3 +18,4 @@
cat bar cat bar
done done
) )
'