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>

Jeff King committed Jul 10, 2024 at 04:34 UTC a5e450144dbc85b5cd7b0e01c6aa7fd30f117ee2
73 files changed +145 -3
t/Makefile
+1 -3
@@ -109,9 +109,7 @@ clean-chainlint:
109 check-chainlint:
110 @mkdir -p '$(CHAINLINTTMP_SQ)' && \
111 for i in $(CHAINLINTTESTS); do \
112 - echo "test_expect_success '$$i' '" && \
113 - sed -e '/^# LINT: /d' chainlint/$$i.test && \
114 - echo "'"; \
112 + sed -e '/^# LINT: /d' chainlint/$$i.test; \
113 done >'$(CHAINLINTTMP_SQ)'/tests && \
114 { \
115 echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \
t/chainlint/arithmetic-expansion.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'arithmetic-expansion' '
2 (
3 foo &&
4 # LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")"
@@ -9,3 +10,4 @@
10 bar=$((42 + 1))
11 baz
12 )
13 +'
t/chainlint/bash-array.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'bash-array' '
2 (
3 foo &&
4 # LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")"
@@ -10,3 +11,4 @@
11 bar=${#bar[@]} &&
12 baz
13 )
14 +'
t/chainlint/blank-line-before-esac.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'blank-line-before-esac' '
2 # LINT: blank line before "esac"
3 test_done () {
4 case "$test_failure" in
@@ -17,3 +18,4 @@ test_done () {
18
19 esac
20 }
21 +'
t/chainlint/blank-line.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'blank-line' '
2 (
3
4 nothing &&
@@ -8,3 +9,4 @@
9
10
11 )
12 +'
t/chainlint/block-comment.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'block-comment' '
2 (
3 {
4 # show a
@@ -6,3 +7,4 @@
7 echo b
8 }
9 )
10 +'
t/chainlint/block.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'block' '
2 (
3 # LINT: missing "&&" after first "echo"
4 foo &&
@@ -25,3 +26,4 @@
26 echo "done"
27 } &&
28 finis
29 +'
t/chainlint/broken-chain.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'broken-chain' '
2 (
3 foo &&
4 # LINT: missing "&&" from "bar"
@@ -6,3 +7,4 @@
7 # LINT: final statement before closing ")" legitimately lacks "&&"
8 wop
9 )
10 +'
t/chainlint/case-comment.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'case-comment' '
2 (
3 case "$x" in
4 # found foo
@@ -9,3 +10,4 @@
10 ;;
11 esac
12 )
13 +'
t/chainlint/case.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'case' '
2 (
3 # LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
4 case "$x" in
@@ -21,3 +22,4 @@
22 case "$y" in 2) false;; esac
23 foobar
24 )
25 +'
t/chainlint/chain-break-background.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chain-break-background' '
2 JGIT_DAEMON_PID= &&
3 git init --bare empty.git &&
4 >empty.git/git-daemon-export-ok &&
@@ -8,3 +9,4 @@ mkfifo jgit_daemon_output &&
9 JGIT_DAEMON_PID=$!
10 } &&
11 test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
12 +'
t/chainlint/chain-break-continue.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chain-break-continue' '
2 git ls-tree --name-only -r refs/notes/many_notes |
3 while read path
4 do
@@ -11,3 +12,4 @@ do
12 return 1
13 fi
14 done
15 +'
t/chainlint/chain-break-false.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chain-break-false' '
2 # LINT: broken &&-chain okay if explicit "false" signals failure
3 if condition not satisified
4 then
@@ -8,3 +9,4 @@ else
9 echo it went okay
10 congratulate user
11 fi
12 +'
t/chainlint/chain-break-return-exit.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chain-break-return-exit' '
2 case "$(git ls-files)" in
3 one) echo pass one ;;
4 # LINT: broken &&-chain okay if explicit "return 1" signals failuire
@@ -21,3 +22,4 @@ for i in 1 2 3 4 ; do
22 git checkout main -b $i || return $?
23 test_commit $i $i $i tag$i || return $?
24 done
25 +'
t/chainlint/chain-break-status.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chain-break-status' '
2 # LINT: broken &&-chain okay if next command handles "$?" explicitly
3 OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
4 test_match_signal 13 "$OUT" &&
@@ -9,3 +10,4 @@ test_match_signal 13 "$OUT" &&
10 test "$ret" = 3
11 } &&
12 test_cmp expect actual
13 +'
t/chainlint/chained-block.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chained-block' '
2 # LINT: start of block chained to preceding command
3 echo nobody home && {
4 test the doohicky
@@ -9,3 +10,4 @@ GIT_EXTERNAL_DIFF=echo git diff | {
10 read path oldfile oldhex oldmode newfile newhex newmode &&
11 test "z$oh" = "z$oldhex"
12 }
13 +'
t/chainlint/chained-subshell.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'chained-subshell' '
2 # LINT: start of subshell chained to preceding command
3 mkdir sub && (
4 cd sub &&
@@ -11,3 +12,4 @@ test -f $s1
12 test $(cat $s2) = tree2path1 &&
13 # LINT: closing subshell ")" correctly detected on same line as "$(...)"
14 test $(cat $s3) = tree3path1)
15 +'
t/chainlint/close-nested-and-parent-together.test
+2
@@ -1,3 +1,5 @@
1 +test_expect_success 'close-nested-and-parent-together' '
2 (cd foo &&
3 (bar &&
4 baz))
5 +'
t/chainlint/close-subshell.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'close-subshell' '
2 # LINT: closing ")" with various decorations ("&&", ">", "|", etc.)
3 (
4 foo
@@ -25,3 +26,4 @@ fuzzle &&
26 (
27 yop
28 )
29 +'
t/chainlint/command-substitution-subsubshell.test
+2
@@ -1,3 +1,5 @@
1 +test_expect_success 'command-substitution-subsubshell' '
2 # LINT: subshell nested in subshell nested in command substitution
3 OUT=$( ((large_git 1>&3) | :) 3>&1 ) &&
4 test_match_signal 13 "$OUT"
5 +'
t/chainlint/command-substitution.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'command-substitution' '
2 (
3 foo &&
4 # LINT: closing ")" of $(...) not misinterpreted as subshell-closing ")"
@@ -9,3 +10,4 @@
10 bar=$(gobble blocks)
11 baz
12 )
13 +'
t/chainlint/comment.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'comment' '
2 (
3 # LINT: swallow comment lines
4 # comment 1
@@ -9,3 +10,4 @@
10 # comment 3
11 # comment 4
12 )
13 +'
t/chainlint/complex-if-in-cuddled-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'complex-if-in-cuddled-loop' '
2 # LINT: "for" loop cuddled with "(" and ")" and nested "if" with complex
3 # LINT: multi-line condition; indented with spaces, not tabs
4 (for i in a b c; do
@@ -9,3 +10,4 @@
10 fi
11 done) &&
12 test ! -f file
13 +'
t/chainlint/cuddled-if-then-else.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'cuddled-if-then-else' '
2 # LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs
3 (if test -z ""; then
4 echo empty
@@ -5,3 +6,4 @@
6 echo bizzy
7 fi) &&
8 echo foobar
9 +'
t/chainlint/cuddled-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'cuddled-loop' '
2 # LINT: "while" loop cuddled with "(" and ")", with embedded (allowed)
3 # LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
4 # LINT: loop; indented with spaces, not tabs
@@ -5,3 +6,4 @@
6 do foobar bop || exit 1
7 done <file ) &&
8 outside subshell
9 +'
t/chainlint/cuddled.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'cuddled' '
2 # LINT: first subshell statement cuddled with opening "("
3 (cd foo &&
4 bar
@@ -20,3 +21,4 @@
21 # LINT: same with missing "&&"
22 (cd foo
23 bar)
24 +'
t/chainlint/double-here-doc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'double-here-doc' '
2 run_sub_test_lib_test_err run-inv-range-start \
3 "--run invalid range start" \
4 --run="a-5" <<-\EOF &&
@@ -10,3 +11,4 @@ check_sub_test_lib_test_err run-inv-range-start \
11 EOF_OUT
12 > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ}
13 EOF_ERR
14 +'
t/chainlint/dqstring-line-splice.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'dqstring-line-splice' '
2 # LINT: line-splice within DQ-string
3 '"
4 echo 'fatal: reword option of --fixup is mutually exclusive with'\
@@ -5,3 +6,4 @@ echo 'fatal: reword option of --fixup is mutually exclusive with'\
6 test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual &&
7 test_cmp expect actual
8 "'
9 +'
t/chainlint/dqstring-no-interpolate.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'dqstring-no-interpolate' '
2 # LINT: regex dollar-sign eol anchor in double-quoted string not special
3 grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out &&
4
@@ -13,3 +14,4 @@ grep "^\\.git\$" output.txt &&
14 cut -d ' ' -f 2 <output | sort >actual &&
15 test_cmp expect actual
16 "'
17 +'
t/chainlint/empty-here-doc.test
+2
@@ -1,5 +1,7 @@
1 +test_expect_success 'empty-here-doc' '
2 git ls-tree $tree path >current &&
3 # LINT: empty here-doc
4 cat >expected <<\EOF &&
5 EOF
6 test_output
7 +'
t/chainlint/exclamation.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'exclamation' '
2 # LINT: "! word" is two tokens
3 if ! condition; then echo nope; else yep; fi &&
4 # LINT: "!word" is single token, not two tokens "!" and "word"
@@ -6,3 +7,4 @@ test_prerequisite !MINGW &&
7 mail uucp!address &&
8 # LINT: "!word!" is single token, not three tokens "!", "word", and "!"
9 echo !whatever!
10 +'
t/chainlint/exit-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'exit-loop' '
2 (
3 for i in a b c
4 do
@@ -25,3 +26,4 @@
26 i=$(($i + 1))
27 done
28 )
29 +'
t/chainlint/exit-subshell.test
+2
@@ -1,6 +1,8 @@
1 +test_expect_success 'exit-subshell' '
2 (
3 # LINT: "|| exit {n}" valid subshell escape without hurting &&-chain
4 foo || exit 1
5 bar &&
6 baz
7 )
8 +'
t/chainlint/for-loop-abbreviated.test
+2
@@ -1,6 +1,8 @@
1 +test_expect_success 'for-loop-abbreviated' '
2 # LINT: for-loop lacking optional "in [word...]" before "do"
3 for it
4 do
5 path=$(expr "$it" : '\([^:]*\)') &&
6 git update-index --add "$path" || exit
7 done
8 +'
t/chainlint/for-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'for-loop' '
2 (
3 # LINT: "for", "do", "done" do not need "&&"
4 for i in a b c
@@ -17,3 +18,4 @@
18 cat $i
19 done
20 )
21 +'
t/chainlint/function.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'function' '
2 # LINT: "()" in function definition not mistaken for subshell
3 sha1_file() {
4 echo "$*" | sed "s#..#.git/objects/&/#"
@@ -11,3 +12,4 @@ remove_object() {
12 }
13
14 sha1_file arg && remove_object arg
15 +'
t/chainlint/here-doc-close-subshell.test
+2
@@ -1,5 +1,7 @@
1 +test_expect_success 'here-doc-close-subshell' '
2 (
3 # LINT: line contains here-doc and closes nested subshell
4 cat <<-\INPUT)
5 fizz
6 INPUT
7 +'
t/chainlint/here-doc-indent-operator.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'here-doc-indent-operator' '
2 # LINT: whitespace between operator "<<-" and tag legal
3 cat >expect <<- EOF &&
4 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
@@ -11,3 +12,4 @@ this is not indented
12 -EOF
13
14 cleanup
15 +'
t/chainlint/here-doc-multi-line-command-subst.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'here-doc-multi-line-command-subst' '
2 (
3 # LINT: line contains here-doc and opens multi-line $(...)
4 x=$(bobble <<-\END &&
@@ -7,3 +8,4 @@
8 wiffle)
9 echo $x
10 )
11 +'
t/chainlint/here-doc-multi-line-string.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'here-doc-multi-line-string' '
2 (
3 # LINT: line contains here-doc and opens multi-line string
4 cat <<-\TXT && echo "multi-line
@@ -6,3 +7,4 @@
7 TXT
8 bap
9 )
10 +'
t/chainlint/here-doc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'here-doc' '
2 # LINT: stitch together incomplete \-ending lines
3 # LINT: swallow here-doc to avoid false positives in content
4 boodle wobba \
@@ -28,3 +29,4 @@ morticia
29 wednesday
30 pugsly
31 EOF
32 +'
t/chainlint/if-condition-split.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'if-condition-split' '
2 # LINT: "if" condition split across multiple lines at "&&" or "||"
3 if bob &&
4 marcia ||
@@ -6,3 +7,4 @@ then
7 echo "nomads"
8 echo "for sure"
9 fi
10 +'
t/chainlint/if-in-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'if-in-loop' '
2 (
3 for i in a b c
4 do
@@ -13,3 +14,4 @@
14 done
15 bar
16 )
17 +'
t/chainlint/if-then-else.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'if-then-else' '
2 (
3 # LINT: "if", "then", "elif", "else", "fi" do not need "&&"
4 if test -n ""
@@ -27,3 +28,4 @@
28 echo empty
29 fi
30 )
31 +'
t/chainlint/incomplete-line.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'incomplete-line' '
2 # LINT: stitch together all incomplete \-ending lines
3 line 1 \
4 line 2 \
@@ -10,3 +11,4 @@ line 4 &&
11 line 7 \
12 line 8
13 )
14 +'
t/chainlint/inline-comment.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'inline-comment' '
2 (
3 # LINT: swallow inline comment (leaving command intact)
4 foobar && # comment 1
@@ -10,3 +11,4 @@
11 # LINT: "#" in string in cuddled subshell not misinterpreted as comment
12 (cd foo &&
13 flibble "not a # comment")
14 +'
t/chainlint/loop-detect-failure.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'loop-detect-failure' '
2 git init r1 &&
3 # LINT: loop handles failure explicitly with "|| return 1"
4 for n in 1 2 3 4 5
@@ -15,3 +16,4 @@ do
16 git -C r2 add large.$n &&
17 git -C r2 commit -m "$n"
18 done
19 +'
t/chainlint/loop-detect-status.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'loop-detect-status' '
2 # LINT: "$?" handled explicitly within loop body
3 (while test $i -le $blobcount
4 do
@@ -17,3 +18,4 @@
18 cat commit) |
19 git fast-import --big-file-threshold=2 &&
20 test ! -f exit-status
21 +'
t/chainlint/loop-in-if.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'loop-in-if' '
2 (
3 if true
4 then
@@ -13,3 +14,4 @@
14 fi
15 bar
16 )
17 +'
t/chainlint/loop-upstream-pipe.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'loop-upstream-pipe' '
2 (
3 git rev-list --objects --no-object-names base..loose |
4 while read oid
@@ -9,3 +10,4 @@
10 done |
11 sort -k1
12 ) >expect &&
13 +'
t/chainlint/multi-line-nested-command-substitution.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'multi-line-nested-command-substitution' '
2 (
3 foo &&
4 x=$(
@@ -16,3 +17,4 @@ sort &&
17 fip) &&
18 echo fail
19 )
20 +'
t/chainlint/multi-line-string.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'multi-line-string' '
2 (
3 x="line 1
4 line 2
@@ -13,3 +14,4 @@
14 ghi" &&
15 barfoo
16 )
17 +'
t/chainlint/negated-one-liner.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'negated-one-liner' '
2 # LINT: top-level one-liner subshell
3 ! (foo && bar) &&
4 ! (foo && bar) >baz &&
@@ -5,3 +6,4 @@
6 # LINT: top-level one-liner subshell missing internal "&&"
7 ! (foo; bar) &&
8 ! (foo; bar) >baz
9 +'
t/chainlint/nested-cuddled-subshell.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'nested-cuddled-subshell' '
2 (
3 # LINT: opening "(" cuddled with first nested subshell statement
4 (cd foo &&
@@ -29,3 +30,4 @@
30
31 foobar
32 )
33 +'
t/chainlint/nested-here-doc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'nested-here-doc' '
2 # LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc
3 cat <<ARBITRARY >foop &&
4 naddle
@@ -31,3 +32,4 @@ ARBITRARY
32
33 foobar
34 )
35 +'
t/chainlint/nested-loop-detect-failure.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'nested-loop-detect-failure' '
2 # LINT: neither loop handles failure explicitly with "|| return 1"
3 for i in 0 1 2 3 4 5 6 7 8 9;
4 do
@@ -33,3 +34,4 @@ do
34 echo "$i$j" >"path$i$j" || return 1
35 done || return 1
36 done
37 +'
t/chainlint/nested-subshell-comment.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'nested-subshell-comment' '
2 (
3 foo &&
4 (
@@ -11,3 +12,4 @@
12 )
13 fuzzy
14 )
15 +'
t/chainlint/nested-subshell.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'nested-subshell' '
2 (
3 cd foo &&
4 (
@@ -11,3 +12,4 @@
12 echo b
13 ) >file
14 )
15 +'
t/chainlint/not-heredoc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'not-heredoc' '
2 # LINT: "<< ours" inside string is not here-doc
3 echo "<<<<<<< ours" &&
4 echo ourside &&
@@ -14,3 +15,4 @@ echo ">>>>>>> theirs" &&
15 echo ">>>>>>> theirs"
16 poodle
17 ) >merged
18 +'
t/chainlint/one-liner-for-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'one-liner-for-loop' '
2 git init dir-rename-and-content &&
3 (
4 cd dir-rename-and-content &&
@@ -8,3 +9,4 @@ git init dir-rename-and-content &&
9 git add foo olddir &&
10 git commit -m "original" &&
11 )
12 +'
t/chainlint/one-liner.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'one-liner' '
2 # LINT: top-level one-liner subshell
3 (foo && bar) &&
4 (foo && bar) |
@@ -10,3 +11,4 @@
11
12 # LINT: ";" in string not misinterpreted as broken &&-chain
13 (foo "bar; baz")
14 +'
t/chainlint/p4-filespec.test
+2
@@ -1,5 +1,7 @@
1 +test_expect_success 'p4-filespec' '
2 (
3 # LINT: Perforce revspec in filespec not misinterpreted as in-line comment
4 p4 print -1 //depot/fiddle#42 >file &&
5 foobar
6 )
7 +'
t/chainlint/pipe.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'pipe' '
2 (
3 # LINT: no "&&" needed on line ending with "|"
4 foo |
@@ -10,3 +11,4 @@
11
12 sunder
13 )
14 +'
t/chainlint/return-loop.test
+2
@@ -1,6 +1,8 @@
1 +test_expect_success 'return-loop' '
2 while test $i -lt $((num - 5))
3 do
4 # LINT: "|| return {n}" valid loop escape outside subshell; no "&&" needed
5 git notes add -m "notes for commit$i" HEAD~$i || return 1
6 i=$((i + 1))
7 done
8 +'
t/chainlint/semicolon.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'semicolon' '
2 (
3 # LINT: missing internal "&&" and ending "&&"
4 cat foo ; echo bar
@@ -23,3 +24,4 @@
24 # LINT: semicolon unnecessary but legitimate
25 echo;
26 done)
27 +'
t/chainlint/sqstring-in-sqstring.test
+2
@@ -1,5 +1,7 @@
1 +test_expect_success 'sqstring-in-sqstring' '
2 # LINT: SQ-string Perl code fragment within SQ-string
3 perl -e '\''
4 defined($_ = -s $_) or die for @ARGV;
5 exit 1 if $ARGV[0] <= $ARGV[1];
6 '\'' test-2-$packname_2.pack test-3-$packname_3.pack
7 +'
t/chainlint/subshell-here-doc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'subshell-here-doc' '
2 (
3 # LINT: stitch together incomplete \-ending lines
4 # LINT: swallow here-doc to avoid false positives in content
@@ -33,3 +34,4 @@ EOF
34 ARBITRARY3
35 meep
36 )
37 +'
t/chainlint/subshell-one-liner.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'subshell-one-liner' '
2 (
3 # LINT: nested one-liner subshell
4 (foo && bar) &&
@@ -22,3 +23,4 @@
23
24 foobar
25 )
26 +'
t/chainlint/t7900-subtree.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 't7900-subtree' '
2 (
3 chks="sub1
4 sub2
@@ -20,3 +21,4 @@ TXT
21 check_equal "$subfiles" "$chkms
22 $chks"
23 )
24 +'
t/chainlint/token-pasting.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'token-pasting' '
2 # LINT: single token; composite of multiple strings
3 git config filter.rot13.smudge ./rot13.sh &&
4 git config filter.rot13.clean ./rot13.sh &&
@@ -30,3 +31,4 @@ downstream_url_for_sed=$(
31 # LINT: exit/enter string context; "&" inside string not command terminator
32 sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
33 )
34 +'
t/chainlint/unclosed-here-doc-indent.test
+2
@@ -1,4 +1,6 @@
1 +test_expect_success 'unclosed-here-doc-indent' '
2 command_which_is_run &&
3 cat >expect <<-\EOF &&
4 we forget to end the here-doc
5 command_which_is_gobbled
6 +'
t/chainlint/unclosed-here-doc.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'unclosed-here-doc' '
2 command_which_is_run &&
3 cat >expect <<\EOF &&
4 we try to end the here-doc below,
@@ -5,3 +6,4 @@ cat >expect <<\EOF &&
6 since the operator is not "<<-".
7 EOF
8 command_which_is_gobbled
9 +'
t/chainlint/while-loop.test
+2
@@ -1,3 +1,4 @@
1 +test_expect_success 'while-loop' '
2 (
3 # LINT: "while", "do", "done" do not need "&&"
4 while true
@@ -17,3 +18,4 @@
18 cat bar
19 done
20 )
21 +'