]> git.ipfire.org Git - thirdparty/git.git/commitdiff
chainlint.pl: add test_expect_success call to test snippets
authorJeff King <peff@peff.net>
Wed, 10 Jul 2024 08:34:48 +0000 (04:34 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jul 2024 17:14:21 +0000 (10:14 -0700)
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>
73 files changed:
t/Makefile
t/chainlint/arithmetic-expansion.test
t/chainlint/bash-array.test
t/chainlint/blank-line-before-esac.test
t/chainlint/blank-line.test
t/chainlint/block-comment.test
t/chainlint/block.test
t/chainlint/broken-chain.test
t/chainlint/case-comment.test
t/chainlint/case.test
t/chainlint/chain-break-background.test
t/chainlint/chain-break-continue.test
t/chainlint/chain-break-false.test
t/chainlint/chain-break-return-exit.test
t/chainlint/chain-break-status.test
t/chainlint/chained-block.test
t/chainlint/chained-subshell.test
t/chainlint/close-nested-and-parent-together.test
t/chainlint/close-subshell.test
t/chainlint/command-substitution-subsubshell.test
t/chainlint/command-substitution.test
t/chainlint/comment.test
t/chainlint/complex-if-in-cuddled-loop.test
t/chainlint/cuddled-if-then-else.test
t/chainlint/cuddled-loop.test
t/chainlint/cuddled.test
t/chainlint/double-here-doc.test
t/chainlint/dqstring-line-splice.test
t/chainlint/dqstring-no-interpolate.test
t/chainlint/empty-here-doc.test
t/chainlint/exclamation.test
t/chainlint/exit-loop.test
t/chainlint/exit-subshell.test
t/chainlint/for-loop-abbreviated.test
t/chainlint/for-loop.test
t/chainlint/function.test
t/chainlint/here-doc-close-subshell.test
t/chainlint/here-doc-indent-operator.test
t/chainlint/here-doc-multi-line-command-subst.test
t/chainlint/here-doc-multi-line-string.test
t/chainlint/here-doc.test
t/chainlint/if-condition-split.test
t/chainlint/if-in-loop.test
t/chainlint/if-then-else.test
t/chainlint/incomplete-line.test
t/chainlint/inline-comment.test
t/chainlint/loop-detect-failure.test
t/chainlint/loop-detect-status.test
t/chainlint/loop-in-if.test
t/chainlint/loop-upstream-pipe.test
t/chainlint/multi-line-nested-command-substitution.test
t/chainlint/multi-line-string.test
t/chainlint/negated-one-liner.test
t/chainlint/nested-cuddled-subshell.test
t/chainlint/nested-here-doc.test
t/chainlint/nested-loop-detect-failure.test
t/chainlint/nested-subshell-comment.test
t/chainlint/nested-subshell.test
t/chainlint/not-heredoc.test
t/chainlint/one-liner-for-loop.test
t/chainlint/one-liner.test
t/chainlint/p4-filespec.test
t/chainlint/pipe.test
t/chainlint/return-loop.test
t/chainlint/semicolon.test
t/chainlint/sqstring-in-sqstring.test
t/chainlint/subshell-here-doc.test
t/chainlint/subshell-one-liner.test
t/chainlint/t7900-subtree.test
t/chainlint/token-pasting.test
t/chainlint/unclosed-here-doc-indent.test
t/chainlint/unclosed-here-doc.test
t/chainlint/while-loop.test

index b2eb9f770bece754e0f025651fa1865f31d6d2da..e7a476966ef7cac231215e7a441862344f1e3ff8 100644 (file)
@@ -109,9 +109,7 @@ clean-chainlint:
 check-chainlint:
        @mkdir -p '$(CHAINLINTTMP_SQ)' && \
        for i in $(CHAINLINTTESTS); do \
-               echo "test_expect_success '$$i' '" && \
-               sed -e '/^# LINT: /d' chainlint/$$i.test && \
-               echo "'"; \
+               sed -e '/^# LINT: /d' chainlint/$$i.test; \
        done >'$(CHAINLINTTMP_SQ)'/tests && \
        { \
                echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \
index 16206960d8b0fe6fac0511d1929d86b8a2dd8198..7b4c5c9a4138541f569d2844559abe033f63cf50 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'arithmetic-expansion' '
 (
        foo &&
 # LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")"
@@ -9,3 +10,4 @@
        bar=$((42 + 1))
        baz
 )
+'
index 92bbb777b82af05900f9c53d0202b70064526439..4ca977d299fbb1c04b14f0f94d458c1c9678487d 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'bash-array' '
 (
        foo &&
 # LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")"
@@ -10,3 +11,4 @@
        bar=${#bar[@]} &&
        baz
 )
+'
index cecccad19f5a9b833c3c0eba6168332c620f5983..51f02ea0c541ac4015f405eb6b982665e42356db 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'blank-line-before-esac' '
 # LINT: blank line before "esac"
 test_done () {
        case "$test_failure" in
@@ -17,3 +18,4 @@ test_done () {
 
        esac
 }
+'
index 0fdf15b3e14c6aaac3bbbc8f2c4f04035845cd4c..6f29a491deed3c67a6f3c91cc62fb430b47d2d71 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'blank-line' '
 (
 
        nothing &&
@@ -8,3 +9,4 @@
 
 
 )
+'
index df2beea8887f3504e5fbab25aef96eb3763ded84..934ef4113a823944ce85cbfa509c1b375dd255fb 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'block-comment' '
 (
        {
                # show a
@@ -6,3 +7,4 @@
                echo b
        }
 )
+'
index 4ab69a4afc40381561b0ccd2a4d7f1abe96c80d1..a1b6b4dd329311055eb672e630adb457421dc084 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'block' '
 (
 # LINT: missing "&&" after first "echo"
        foo &&
@@ -25,3 +26,4 @@
        echo "done"
 } &&
 finis
+'
index 2a44aa73b71a9794c4b51d7c13dc71ab25239596..1966499ef963b522962e9a5541e64466de271f03 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'broken-chain' '
 (
        foo &&
 # LINT: missing "&&" from "bar"
@@ -6,3 +7,4 @@
 # LINT: final statement before closing ")" legitimately lacks "&&"
        wop
 )
+'
index 641c157b98c0af678b15fb2cc25645eac8650602..3f31ae901035496343592531b5bc22a61c919a05 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'case-comment' '
 (
        case "$x" in
        # found foo
@@ -9,3 +10,4 @@
                ;;
        esac
 )
+'
index 4cb086bf87b04c709601ca610aad6db39bbd8bb4..bea21fee4f468d67385f55209b2ca85fe68b469e 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'case' '
 (
 # LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
        case "$x" in
@@ -21,3 +22,4 @@
        case "$y" in 2) false;; esac
        foobar
 )
+'
index e10f656b0556d77ed9125abe47af38ee44828c88..c68e1b04d5eefce7367a7131d176d05e31d028dd 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chain-break-background' '
 JGIT_DAEMON_PID= &&
 git init --bare empty.git &&
 >empty.git/git-daemon-export-ok &&
@@ -8,3 +9,4 @@ mkfifo jgit_daemon_output &&
        JGIT_DAEMON_PID=$!
 } &&
 test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
+'
index f0af71d8bd914a7bd2785caf40facc7360e8b43c..de8119b2049ba37592c3a67d7582e8ccf81a640e 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chain-break-continue' '
 git ls-tree --name-only -r refs/notes/many_notes |
 while read path
 do
@@ -11,3 +12,4 @@ do
                return 1
        fi
 done
+'
index a5aaff8c8a4290fe32eeb231787b368dc131fd9e..f78ad911fcd3455e7564edfcceefc74285e5948c 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chain-break-false' '
 # LINT: broken &&-chain okay if explicit "false" signals failure
 if condition not satisified
 then
@@ -8,3 +9,4 @@ else
        echo it went okay
        congratulate user
 fi
+'
index 46542edf8819166e56cfa46feae37b64f4747c5b..b6f519bb4dbc0e7ec586a3f15826da5a84b06753 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chain-break-return-exit' '
 case "$(git ls-files)" in
 one) echo pass one ;;
 # 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 $?
        test_commit $i $i $i tag$i || return $?
 done
+'
index a6602a7b99cfc7f2d19148b07ebe15d32c22e824..d9fee190d999094a9e47d1b465aa2ebc1b5b85e7 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chain-break-status' '
 # LINT: broken &&-chain okay if next command handles "$?" explicitly
 OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
 test_match_signal 13 "$OUT" &&
@@ -9,3 +10,4 @@ test_match_signal 13 "$OUT" &&
        test "$ret" = 3
 } &&
 test_cmp expect actual
+'
index 86f81ece63903fb91e0ed861d01bb38f896fabd2..71ef1d0b7f005247b6aab72e70ec34ce4c05a9db 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chained-block' '
 # LINT: start of block chained to preceding command
 echo nobody home && {
        test the doohicky
@@ -9,3 +10,4 @@ GIT_EXTERNAL_DIFF=echo git diff | {
        read path oldfile oldhex oldmode newfile newhex newmode &&
        test "z$oh" = "z$oldhex"
 }
+'
index 4ff6ddd8cbd078d3288cc4611a66bb4fbe7c4a04..1f11f653982fa6239752388deb20f0d4db74640c 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'chained-subshell' '
 # LINT: start of subshell chained to preceding command
 mkdir sub && (
        cd sub &&
@@ -11,3 +12,4 @@ test -f $s1
 test $(cat $s2) = tree2path1 &&
 # LINT: closing subshell ")" correctly detected on same line as "$(...)"
 test $(cat $s3) = tree3path1)
+'
index 72d482f76dd20f0d2ca7bbffd177417a257992e2..56b28b186b34e44c003de0a1dc68f98ee8ed892e 100644 (file)
@@ -1,3 +1,5 @@
+test_expect_success 'close-nested-and-parent-together' '
 (cd foo &&
        (bar &&
                baz))
+'
index 508ca447fd6c8badde4cea7dce6d141e8fea9bca..b99f80569d5fbf82bc820d2f3bf4166edc5dc323 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'close-subshell' '
 # LINT: closing ")" with various decorations ("&&", ">", "|", etc.)
 (
        foo
@@ -25,3 +26,4 @@ fuzzle &&
 (
        yop
 )
+'
index 321de2951ce13f06c2d2b589624aac3cfb6b514f..4ea772d60ad3c1c8c95c3bd599afb478a7f01b6d 100644 (file)
@@ -1,3 +1,5 @@
+test_expect_success 'command-substitution-subsubshell' '
 # LINT: subshell nested in subshell nested in command substitution
 OUT=$( ((large_git 1>&3) | :) 3>&1 ) &&
 test_match_signal 13 "$OUT"
+'
index 3bbb002a4c746c8e4cdd4cb9b80e60224b3bd2a9..494d671e80ab6698bbf0c24b2dc542e29539908f 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'command-substitution' '
 (
        foo &&
 # LINT: closing ")" of $(...) not misinterpreted as subshell-closing ")"
@@ -9,3 +10,4 @@
        bar=$(gobble blocks)
        baz
 )
+'
index 113c0c466f1741b1bf4fc68f666347b3b511104a..c488beac0db607f5cf964b3f8873d42a990eab8b 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'comment' '
 (
 # LINT: swallow comment lines
        # comment 1
@@ -9,3 +10,4 @@
        # comment 3
        # comment 4
 )
+'
index 5efeda58b2a7196d74999a514268ef0099f661d6..f98ae4c42df287d6ac0124cbead7799124c1baf0 100644 (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: multi-line condition; indented with spaces, not tabs
 (for i in a b c; do
@@ -9,3 +10,4 @@
    fi
  done) &&
 test ! -f file
+'
index 7c53f4efe3eba3c3da52e620a89e87c371e15db3..b1b42e1aac8d90b2894f70c65de897247baec9f9 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'cuddled-if-then-else' '
 # LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs
 (if test -z ""; then
     echo empty
@@ -5,3 +6,4 @@
     echo bizzy
  fi) &&
 echo foobar
+'
index 3c2a62f7518937e86ff2723f62e17be9d28e8eda..6fccb6ac22a5781484659312d37a0d2a5986ca3a 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'cuddled-loop' '
 # LINT: "while" loop cuddled with "(" and ")", with embedded (allowed)
 # LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
 # LINT: loop; indented with spaces, not tabs
@@ -5,3 +6,4 @@
   do foobar bop || exit 1
   done <file ) &&
 outside subshell
+'
index 257b5b5eed3a23a6549f3a6f2b5ea77a776ad7e9..5a6ef7a4a6d098a39e31be519943cc74d74947fb 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'cuddled' '
 # LINT: first subshell statement cuddled with opening "("
 (cd foo &&
        bar
@@ -20,3 +21,4 @@
 # LINT: same with missing "&&"
 (cd foo
        bar)
+'
index cd584a435730045608f1ce9162274fb6fa53a2c8..1b69b7a651caac8416b61be30317e2651b83829c 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'double-here-doc' '
 run_sub_test_lib_test_err run-inv-range-start \
        "--run invalid range start" \
        --run="a-5" <<-\EOF &&
@@ -10,3 +11,4 @@ check_sub_test_lib_test_err run-inv-range-start \
 EOF_OUT
 > error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ}
 EOF_ERR
+'
index b40714439f6fc8e16420b966ffb475fbe3f71c4c..f6aa637be887af6e375be22246313ee0f8152efa 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'dqstring-line-splice' '
 # LINT: line-splice within DQ-string
 '"
 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_cmp expect actual
 "'
+'
index d2f4219cbbbcd70da5ab4d29fcf8120b5fc23d39..7ae079b558b00add6713819f498e87da61598254 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'dqstring-no-interpolate' '
 # LINT: regex dollar-sign eol anchor in double-quoted string not special
 grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" out &&
 
@@ -13,3 +14,4 @@ grep "^\\.git\$" output.txt &&
        cut -d ' ' -f 2 <output | sort >actual &&
        test_cmp expect actual
 "'
+'
index 24fc165de3f15f5b98a7131272497d6a82921376..8b7ab6eb5f6cf5c5c0472aa356217545bf296e2b 100644 (file)
@@ -1,5 +1,7 @@
+test_expect_success 'empty-here-doc' '
 git ls-tree $tree path >current &&
 # LINT: empty here-doc
 cat >expected <<\EOF &&
 EOF
 test_output
+'
index 323595b5bd86359b6022a6ce783d77a722fc78b5..796de21b7c568b088fdd219718b46423944a74ce 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'exclamation' '
 # LINT: "! word" is two tokens
 if ! condition; then echo nope; else yep; fi &&
 # LINT: "!word" is single token, not two tokens "!" and "word"
@@ -6,3 +7,4 @@ test_prerequisite !MINGW &&
 mail uucp!address &&
 # LINT: "!word!" is single token, not three tokens "!", "word", and "!"
 echo !whatever!
+'
index 2f038207e194ca0c51106205b3d57f4c7d1d7881..7e8b68b46588b90c935a8c4fe7ad0d31c1bb126d 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'exit-loop' '
 (
        for i in a b c
        do
@@ -25,3 +26,4 @@
                i=$(($i + 1))
        done
 )
+'
index 4e6ab69b88674291d9e786da04f88106ff509ccd..05dff55cd73e399ac02f01815f9cf23ab1f8e0b0 100644 (file)
@@ -1,6 +1,8 @@
+test_expect_success 'exit-subshell' '
 (
 # LINT: "|| exit {n}" valid subshell escape without hurting &&-chain
        foo || exit 1
        bar &&
        baz
 )
+'
index 1084eccb89c1eb35ba329c3ccf371c9aa17ac69c..1dd14f2a445d07d4a499c623efbd63ad9d4d45a4 100644 (file)
@@ -1,6 +1,8 @@
+test_expect_success 'for-loop-abbreviated' '
 # LINT: for-loop lacking optional "in [word...]" before "do"
 for it
 do
        path=$(expr "$it" : '\([^:]*\)') &&
        git update-index --add "$path" || exit
 done
+'
index 6cb34281582055b118b75f37a006e6c3ae5c962c..6f2489eb192d942759bb2c9ced82f67e1cd601d0 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'for-loop' '
 (
 # LINT: "for", "do", "done" do not need "&&"
        for i in a b c
@@ -17,3 +18,4 @@
                cat $i
        done
 )
+'
index 5ee59562c93f365d6f990bf4dab0c90fb017c6bb..763fcf3f878d50b41bca879f752da76048bc7546 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'function' '
 # LINT: "()" in function definition not mistaken for subshell
 sha1_file() {
        echo "$*" | sed "s#..#.git/objects/&/#"
@@ -11,3 +12,4 @@ remove_object() {
 }
 
 sha1_file arg && remove_object arg
+'
index b857ff54676536a8d12ed0894bb8e2e48a12e8e2..2458f3323b4952e069a385b20d135f6b668991a9 100644 (file)
@@ -1,5 +1,7 @@
+test_expect_success 'here-doc-close-subshell' '
 (
 # LINT: line contains here-doc and closes nested subshell
        cat <<-\INPUT)
        fizz
        INPUT
+'
index c8a6f18eb4540f19f39dffea71fa650ab6f0c6e2..a2656f47c1e4fa28c14b31ae81fe84336e44fa23 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'here-doc-indent-operator' '
 # LINT: whitespace between operator "<<-" and tag legal
 cat >expect <<- EOF &&
 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
@@ -11,3 +12,4 @@ this is not indented
 -EOF
 
 cleanup
+'
index 899bc5de8bceca9a58cfb8513a2b4f542c2fc19e..8710a8c4837f1be653de2f229f2b9eaef7fe7d89 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'here-doc-multi-line-command-subst' '
 (
 # LINT: line contains here-doc and opens multi-line $(...)
        x=$(bobble <<-\END &&
@@ -7,3 +8,4 @@
                wiffle)
        echo $x
 )
+'
index a53edbcc8d89bc2fd693da6bb410f0e2dc179d5d..2f496002fdbcac1d6783c79007151a5115586304 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'here-doc-multi-line-string' '
 (
 # LINT: line contains here-doc and opens multi-line string
        cat <<-\TXT && echo "multi-line
@@ -6,3 +7,4 @@
        TXT
        bap
 )
+'
index 3f5f92cad34761a1daffa00e819a08c1fc5a07a1..c91b6953197cce758fef8c52f92961ad3780d440 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'here-doc' '
 # LINT: stitch together incomplete \-ending lines
 # LINT: swallow here-doc to avoid false positives in content
 boodle wobba \
@@ -28,3 +29,4 @@ morticia
 wednesday
 pugsly
 EOF
+'
index 240daa9fd5d67db8bd10e0b7d6da9f94d3a6d29f..9a3b3ed04aa00485f4224e1aca9a0513cc6a0fe6 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'if-condition-split' '
 # LINT: "if" condition split across multiple lines at "&&" or "||"
 if bob &&
    marcia ||
@@ -6,3 +7,4 @@ then
        echo "nomads"
        echo "for sure"
 fi
+'
index 90c23976feccdd3f3851a39cf7b12cb5f643f628..5be9d1cfa585ee58d88169dffb7cbf5413744623 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'if-in-loop' '
 (
        for i in a b c
        do
@@ -13,3 +14,4 @@
        done
        bar
 )
+'
index 2055336c2b9ed2e975b21d20310f2821bbef7b6f..6582a7f440239b8762c81c9da0c3f3f993c056cf 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'if-then-else' '
 (
 # LINT: "if", "then", "elif", "else", "fi" do not need "&&"
        if test -n ""
@@ -27,3 +28,4 @@
                echo empty
        fi
 )
+'
index d8566580839bc488e7168f6195af043a613daee5..74a93021ebcd4825332cd1ccc17ec9c79889b168 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'incomplete-line' '
 # LINT: stitch together all incomplete \-ending lines
 line 1 \
 line 2 \
@@ -10,3 +11,4 @@ line 4 &&
        line 7 \
        line 8
 )
+'
index 8f26856e775b569871849f62856a27013de44be3..4fbbf1058a0ec2d69af1a53d3ce3d053040e518e 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'inline-comment' '
 (
 # LINT: swallow inline comment (leaving command intact)
        foobar && # comment 1
@@ -10,3 +11,4 @@
 # LINT: "#" in string in cuddled subshell not misinterpreted as comment
 (cd foo &&
        flibble "not a # comment")
+'
index b9791cc802e6610e8cafa25fd21e189031279c0e..44673aa394ff907ba93fb0a4730c02f045514326 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'loop-detect-failure' '
 git init r1 &&
 # LINT: loop handles failure explicitly with "|| return 1"
 for n in 1 2 3 4 5
@@ -15,3 +16,4 @@ do
        git -C r2 add large.$n &&
        git -C r2 commit -m "$n"
 done
+'
index 1c6c23cfc9ebaeb83d3d4aeba44ddd2edb705395..8b639be073f03857b7fe1d28f333a66f80fdf0f4 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'loop-detect-status' '
 # LINT: "$?" handled explicitly within loop body
 (while test $i -le $blobcount
  do
@@ -17,3 +18,4 @@
  cat commit) |
 git fast-import --big-file-threshold=2 &&
 test ! -f exit-status
+'
index dfcc3f98fb11ce442100f39c844382e2719997ae..b0d0d393cfeb1e66a63e4263cf88c44e4993a40c 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'loop-in-if' '
 (
        if true
        then
@@ -13,3 +14,4 @@
        fi
        bar
 )
+'
index efb77da897c6f145ec4d858f7134147469bf5bc1..8415a4db27db5a4e45186a6829f3714c6f01bcfe 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'loop-upstream-pipe' '
 (
        git rev-list --objects --no-object-names base..loose |
        while read oid
@@ -9,3 +10,4 @@
        done |
        sort -k1
 ) >expect &&
+'
index 300058341b6f303dce9d8e8105b6f16fa25f2ebf..e811c63f2bca4217da16ad40552bd1d8ece87be9 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'multi-line-nested-command-substitution' '
 (
        foo &&
        x=$(
@@ -16,3 +17,4 @@ sort &&
                fip) &&
        echo fail
 )
+'
index 4a0af2107da6dfb0035ead1ada8add0353cc2199..7b5048d2ea17fe1db337e86f617db3dc0d2c49ef 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'multi-line-string' '
 (
        x="line 1
                line 2
@@ -13,3 +14,4 @@
                ghi" &&
        barfoo
 )
+'
index c9598e915307fd05568fa626aae83542b244097a..30f4cc5a9b21f94b3d5b78c7fc57e7b141947088 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'negated-one-liner' '
 # LINT: top-level one-liner subshell
 ! (foo && bar) &&
 ! (foo && bar) >baz &&
@@ -5,3 +6,4 @@
 # LINT: top-level one-liner subshell missing internal "&&"
 ! (foo; bar) &&
 ! (foo; bar) >baz
+'
index 8fd656c7b598acfb19f026f1368f75e980766f04..31e92d3be4aceaf6cc5ac80d7b7a3857c1f862ad 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'nested-cuddled-subshell' '
 (
 # LINT: opening "(" cuddled with first nested subshell statement
        (cd foo &&
@@ -29,3 +30,4 @@
 
        foobar
 )
+'
index f35404bf0f9313f33040d49b685d087d4f11b29b..9505c47a345c314817892257d8dc9e5cbc88b350 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'nested-here-doc' '
 # LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc
 cat <<ARBITRARY >foop &&
 naddle
@@ -31,3 +32,4 @@ ARBITRARY
 
        foobar
 )
+'
index e6f0c1acfb8b263df84abd12d8d84798c71aa821..3d4b6574126046401b7cfa14f087dd9c04e298dd 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'nested-loop-detect-failure' '
 # LINT: neither loop handles failure explicitly with "|| return 1"
 for i in 0 1 2 3 4 5 6 7 8 9;
 do
@@ -33,3 +34,4 @@ do
                echo "$i$j" >"path$i$j" || return 1
        done || return 1
 done
+'
index 0215cdb1921b5bf27c302ffdf4c48e5bf5a4848a..b430580ce0e76cbb06105ea72fe109693f888ffc 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'nested-subshell-comment' '
 (
        foo &&
        (
@@ -11,3 +12,4 @@
        )
        fuzzy
 )
+'
index 440ee9992da3491a85fae254bdb7eb14176d4a29..c31da34b73a9e1d1731f6b3046d6cd4bbbabf488 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'nested-subshell' '
 (
        cd foo &&
        (
@@ -11,3 +12,4 @@
                echo b
        ) >file
 )
+'
index 9aa57346cd7d747351b635264c77f4fd2ee4d2ff..09711e45e052e6eb26dfc64625f75408b51f7ae8 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'not-heredoc' '
 # LINT: "<< ours" inside string is not here-doc
 echo "<<<<<<< ours" &&
 echo ourside &&
@@ -14,3 +15,4 @@ echo ">>>>>>> theirs" &&
        echo ">>>>>>> theirs"
        poodle
 ) >merged
+'
index 4bd8c066c799639ba3dcbfb844a90df1fa88fd2e..00afd7ef76ee8c1284f46cf9f6b67299c85dc760 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'one-liner-for-loop' '
 git init dir-rename-and-content &&
 (
        cd dir-rename-and-content &&
@@ -8,3 +9,4 @@ git init dir-rename-and-content &&
        git add foo olddir &&
        git commit -m "original" &&
 )
+'
index be9858fa29efbe862bf07269a35abe7324568e22..6e42ee1b5eb0f6a3a31b8413856ffef53c78a6e2 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'one-liner' '
 # LINT: top-level one-liner subshell
 (foo && bar) &&
 (foo && bar) |
@@ -10,3 +11,4 @@
 
 # LINT: ";" in string not misinterpreted as broken &&-chain
 (foo "bar; baz")
+'
index 4fd2d6e2b80bfc15725875d18ad84b3c1c4255dd..8ba6b911dcb1be71cc91833abd53fd3e84e5cd41 100644 (file)
@@ -1,5 +1,7 @@
+test_expect_success 'p4-filespec' '
 (
 # LINT: Perforce revspec in filespec not misinterpreted as in-line comment
        p4 print -1 //depot/fiddle#42 >file &&
        foobar
 )
+'
index dd82534c6678624eb259c70d51f7a61fab603994..1af81c243b042689c43993470191ad37e1ea3039 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'pipe' '
 (
 # LINT: no "&&" needed on line ending with "|"
        foo |
@@ -10,3 +11,4 @@
 
        sunder
 )
+'
index f90b1713005b0ddc48a0f35be6447894d79680d7..ea76c3593ade55a542b096868590c0346ab11cfd 100644 (file)
@@ -1,6 +1,8 @@
+test_expect_success 'return-loop' '
 while test $i -lt $((num - 5))
 do
 # LINT: "|| return {n}" valid loop escape outside subshell; no "&&" needed
        git notes add -m "notes for commit$i" HEAD~$i || return 1
        i=$((i + 1))
 done
+'
index 67e1192c50ab0c47a74152a4fd59a6d70797b717..fc0ba1b5397916db466522a2f770a05d718a9cba 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'semicolon' '
 (
 # LINT: missing internal "&&" and ending "&&"
        cat foo ; echo bar
@@ -23,3 +24,4 @@
 # LINT: semicolon unnecessary but legitimate
                echo;
        done)
+'
index 77a425e0c795c5253b54a6cc9dd67df8d7d46f64..24169724a53dfb612f7745d4cebd284bbfc744b2 100644 (file)
@@ -1,5 +1,7 @@
+test_expect_success 'sqstring-in-sqstring' '
 # LINT: SQ-string Perl code fragment within SQ-string
 perl -e '\''
        defined($_ = -s $_) or die for @ARGV;
        exit 1 if $ARGV[0] <= $ARGV[1];
 '\'' test-2-$packname_2.pack test-3-$packname_3.pack
+'
index d40eb65583f92f375dddbd3db76a893562724703..4a38f47f0121931bfd9fed02609f38d9f13fe6ae 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'subshell-here-doc' '
 (
 # LINT: stitch together incomplete \-ending lines
 # LINT: swallow here-doc to avoid false positives in content
@@ -33,3 +34,4 @@ EOF
        ARBITRARY3
        meep
 )
+'
index 37fa643c20a9bf65a573c1f67c3c6729006767b0..dac536afcc37cbe38b063eb06e0e32dda1a98f69 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'subshell-one-liner' '
 (
 # LINT: nested one-liner subshell
        (foo && bar) &&
@@ -22,3 +23,4 @@
 
        foobar
 )
+'
index 02f3129232a0d114bf90211b9a6508385d0115bd..1f4f03300f425fa10974f00c74cdf7afe4a97601 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 't7900-subtree' '
 (
        chks="sub1
 sub2
@@ -20,3 +21,4 @@ TXT
        check_equal "$subfiles" "$chkms
 $chks"
 )
+'
index b4610ce815af71a398d9d03911f1663972e233f6..590914b73390aa6f8c5ff6e2501bd11ed6a696c5 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'token-pasting' '
 # LINT: single token; composite of multiple strings
 git config filter.rot13.smudge ./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
        sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
 )
+'
index 5c841a9dfd4d2ab13b7f5ea058708b9a7f1c41d3..7ac9d0f7d74741922cfc1e7ff7c9f4a26f23ad57 100644 (file)
@@ -1,4 +1,6 @@
+test_expect_success 'unclosed-here-doc-indent' '
 command_which_is_run &&
 cat >expect <<-\EOF &&
 we forget to end the here-doc
 command_which_is_gobbled
+'
index 69d3786c3489634575772ec45fa0bdeedd75fecc..68e78f06f3e6e7d488c6b5cc0c156d5158c197fb 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'unclosed-here-doc' '
 command_which_is_run &&
 cat >expect <<\EOF &&
        we try to end the here-doc below,
@@ -5,3 +6,4 @@ cat >expect <<\EOF &&
        since the operator is not "<<-".
        EOF
 command_which_is_gobbled
+'
index d09fb016e4405c5d9f7378b2ee5b9a634c4a9dc2..33a201906a8e8c57ca3a4cbc6979fc56c644c3c3 100644 (file)
@@ -1,3 +1,4 @@
+test_expect_success 'while-loop' '
 (
 # LINT: "while", "do", "done" do not need "&&"
        while true
@@ -17,3 +18,4 @@
                cat bar
        done
 )
+'