]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/chainlint/*.test: don't use invalid shell syntax
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Dec 2021 06:30:45 +0000 (01:30 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2021 22:15:28 +0000 (14:15 -0800)
The chainlint self-test code snippets are supposed to represent the body
of a test_expect_success() or test_expect_failure(), yet the contents of
these tests would have caused the shell to report syntax errors had they
been real test bodies. Although chainlint.sed, with its simplistic
heuristics, is blind to these syntactic problems, a future more robust
chainlint implementation might not have such a limitation, so make these
snippets syntactically valid.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint/if-then-else.expect
t/chainlint/if-then-else.test
t/chainlint/subshell-here-doc.test

index 5953c7bfbc2e792af695f1f711ea06662a61dcb5..a80f5e6c75f73a8c6972f1acccfa9157749b4829 100644 (file)
@@ -4,6 +4,7 @@
 ?!AMP?!                echo very
                echo empty
        elif test -z ""
+       then
                echo foo
        else
                echo foo &&
@@ -14,6 +15,6 @@
 (
        if test -n ""; then
                echo very &&
-?!AMP?!                echo empty
-       if
+               echo empty
+       fi
 >)
index 9bd8e9a4c68c2b3b5fd367c6b28763d9765d7d5d..d2b03ca6b4433c91baa8977bc227c84407776556 100644 (file)
@@ -7,6 +7,7 @@
 # LINT: last statement before 'elif' does not need "&&"
                echo empty
        elif test -z ""
+       then
 # LINT: last statement before 'else' does not need "&&"
                echo foo
        else
@@ -24,5 +25,5 @@
        if test -n ""; then
                echo very &&
                echo empty
-       if
+       fi
 )
index f6b3ba4214a41de2ca9f9b91d2407e2f9dc4683c..0cce907ba8d9757aa342404a4b2ba0cb3eb9eea5 100644 (file)
@@ -11,7 +11,7 @@
 # LINT: missing "&&" on 'cat'
        cat <<EOF >bip
        fish fly high
-       EOF
+EOF
 
 # LINT: swallow here-doc (EOF is last line of subshell)
        echo <<-\EOF >bop