]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/chainlint/*.test: fix invalid test cases due to mixing quote types
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Dec 2021 06:30:46 +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
a few tests would have caused the shell to report syntax errors had they
been real test bodies due to the mix of single- and double-quotes.
Although chainlint.sed, with its simplistic heuristics, is blind to this
problem, a future more robust chainlint implementation might not have
such a limitation. Therefore, stop mixing quote types haphazardly in
those tests and unify quoting throughout. While at it, drop chunks of
tests which merely repeat what is already tested elsewhere but with
alternative quotes.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 files changed:
t/chainlint/broken-chain.test
t/chainlint/case.test
t/chainlint/complex-if-in-cuddled-loop.test
t/chainlint/cuddled-if-then-else.test
t/chainlint/cuddled-loop.test
t/chainlint/for-loop.test
t/chainlint/here-doc.expect
t/chainlint/here-doc.test
t/chainlint/if-in-loop.test
t/chainlint/if-then-else.test
t/chainlint/loop-in-if.test
t/chainlint/multi-line-string.expect
t/chainlint/multi-line-string.test
t/chainlint/nested-subshell-comment.test
t/chainlint/pipe.test
t/chainlint/subshell-here-doc.expect
t/chainlint/subshell-here-doc.test
t/chainlint/t7900-subtree.expect
t/chainlint/t7900-subtree.test
t/chainlint/while-loop.test

index 3cc67b65d0c9ddf6739c9060c7cf3ff45fa277b8..2a44aa73b71a9794c4b51d7c13dc71ab25239596 100644 (file)
@@ -1,6 +1,6 @@
 (
        foo &&
-# LINT: missing "&&" from 'bar'
+# LINT: missing "&&" from "bar"
        bar
        baz &&
 # LINT: final statement before closing ")" legitimately lacks "&&"
index 5ef6ff7db5eafbc0abb835901e321ed13265a025..4cb086bf87b04c709601ca610aad6db39bbd8bb4 100644 (file)
@@ -1,5 +1,5 @@
 (
-# LINT: "...)" arms in 'case' not misinterpreted as subshell-closing ")"
+# LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
        case "$x" in
        x) foo ;;
        *) bar ;;
@@ -7,7 +7,7 @@
        foobar
 ) &&
 (
-# LINT: missing "&&" on 'esac'
+# LINT: missing "&&" on "esac"
        case "$x" in
        x) foo ;;
        *) bar ;;
@@ -15,7 +15,7 @@
        foobar
 ) &&
 (
-# LINT: "...)" arm in one-liner 'case' not misinterpreted as closing ")"
+# LINT: "...)" arm in one-liner "case" not misinterpreted as closing ")"
        case "$x" in 1) true;; esac &&
 # LINT: same but missing "&&"
        case "$y" in 2) false;; esac
index 571bbd85cdfc41031de1026bb3c24ae3a9a604f7..5efeda58b2a7196d74999a514268ef0099f661d6 100644 (file)
@@ -1,4 +1,4 @@
-# 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
 (for i in a b c; do
    if test "$(echo $(waffle bat))" = "eleventeen" &&
index eed774a9d64390449699238b4ad0e16c58c15390..7c53f4efe3eba3c3da52e620a89e87c371e15db3 100644 (file)
@@ -1,4 +1,4 @@
-# LINT: 'if' cuddled with "(" and ")"; indented with spaces, not tabs
+# LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs
 (if test -z ""; then
     echo empty
  else
index a841d781f04f01ff1c906027d0b139fb854d4fb9..3c2a62f7518937e86ff2723f62e17be9d28e8eda 100644 (file)
@@ -1,4 +1,4 @@
-# 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: loop; indented with spaces, not tabs
 ( while read x
index 7db76262bc2e0089ea97581417b7ca95b2c9c2b4..6cb34281582055b118b75f37a006e6c3ae5c962c 100644 (file)
@@ -1,17 +1,17 @@
 (
-# LINT: 'for', 'do', 'done' do not need "&&"
+# LINT: "for", "do", "done" do not need "&&"
        for i in a b c
        do
-# LINT: missing "&&" on 'echo'
+# LINT: missing "&&" on "echo"
                echo $i
 # LINT: last statement of while does not need "&&"
                cat <<-\EOF
                bar
                EOF
-# LINT: missing "&&" on 'done'
+# LINT: missing "&&" on "done"
        done
 
-# LINT: 'do' on same line as 'for'
+# LINT: "do" on same line as "for"
        for i in a b c; do
                echo $i &&
                cat $i
index 534b065e38baa213da2a224e147cd41c649e55e8..8449eb2e02a5f982f1ee8021ec32ed175ee55967 100644 (file)
@@ -2,8 +2,6 @@ boodle wobba        gorgo snoot        wafta snurb &&
 
 cat >foo &&
 
-cat >bar &&
-
 cat >boo &&
 
 horticulture
index ad4ce8afd9b55650a2ce3751fbef3d67d07d534d..3f5f92cad34761a1daffa00e819a08c1fc5a07a1 100644 (file)
@@ -14,13 +14,6 @@ boz
 woz
 Arbitrary_Tag_42
 
-# LINT: swallow 'quoted' here-doc
-cat <<'FUMP' >bar &&
-snoz
-boz
-woz
-FUMP
-
 # LINT: swallow "quoted" here-doc
 cat <<"zump" >boo &&
 snoz
index daf22da16476aac9e7467bf73cae8470fe29e98f..f0cf19cfadac8c1ae9d09a668bafc99517c50cdf 100644 (file)
@@ -3,13 +3,13 @@
        do
                if false
                then
-# LINT: missing "&&" on 'echo'
+# LINT: missing "&&" on "echo"
                        echo "err"
                        exit 1
-# LINT: missing "&&" on 'fi'
+# LINT: missing "&&" on "fi"
                fi
                foo
-# LINT: missing "&&" on 'done'
+# LINT: missing "&&" on "done"
        done
        bar
 )
index d2b03ca6b4433c91baa8977bc227c84407776556..2055336c2b9ed2e975b21d20310f2821bbef7b6f 100644 (file)
@@ -1,27 +1,27 @@
 (
-# LINT: 'if', 'then', 'elif', 'else', 'fi' do not need "&&"
+# LINT: "if", "then", "elif", "else", "fi" do not need "&&"
        if test -n ""
        then
-# LINT: missing "&&" on 'echo'
+# LINT: missing "&&" on "echo"
                echo very
-# LINT: last statement before 'elif' does not need "&&"
+# LINT: last statement before "elif" does not need "&&"
                echo empty
        elif test -z ""
        then
-# LINT: last statement before 'else' does not need "&&"
+# LINT: last statement before "else" does not need "&&"
                echo foo
        else
                echo foo &&
-# LINT: last statement before 'fi' does not need "&&"
+# LINT: last statement before "fi" does not need "&&"
                cat <<-\EOF
                bar
                EOF
-# LINT: missing "&&" on 'fi'
+# LINT: missing "&&" on "fi"
        fi
        echo poodle
 ) &&
 (
-# LINT: 'then' on same line as 'if'
+# LINT: "then" on same line as "if"
        if test -n ""; then
                echo very &&
                echo empty
index 93e8ba8e4d9acdefcd9f6e716c6e109cf790ee45..dfcc3f98fb11ce442100f39c844382e2719997ae 100644 (file)
@@ -3,13 +3,13 @@
        then
                while true
                do
-# LINT: missing "&&" on 'echo'
+# LINT: missing "&&" on "echo"
                        echo "pop"
                        echo "glup"
-# LINT: missing "&&" on 'done'
+# LINT: missing "&&" on "done"
                done
                foo
-# LINT: missing "&&" on 'fi'
+# LINT: missing "&&" on "fi"
        fi
        bar
 )
index 170cb5999322ea7798bceafb2222274c4112adde..2829516495b73e7680bf0c650a6f53e4bcc37439 100644 (file)
@@ -1,15 +1,9 @@
 (
        x="line 1               line 2          line 3" &&
-?!AMP?!        y='line 1               line2'
+?!AMP?!        y="line 1               line2"
        foobar
 >) &&
-(
-       echo "there's nothing to see here" &&
-       exit
->) &&
 (
        echo "xyz" "abc         def             ghi" &&
-       echo 'xyz' 'abc         def             ghi' &&
-       echo 'xyz' "abc         def             ghi" &&
        barfoo
 >)
index 287ab897054874972076ec6913bf8c8144196296..4a0af2107da6dfb0035ead1ada8add0353cc2199 100644 (file)
@@ -3,25 +3,13 @@
                line 2
                line 3" &&
 # LINT: missing "&&" on assignment
-       y='line 1
-               line2'
+       y="line 1
+               line2"
        foobar
 ) &&
-(
-# LINT: apostrophe (in a contraction) within string not misinterpreted as
-# LINT: starting multi-line single-quoted string
-       echo "there's nothing to see here" &&
-       exit
-) &&
 (
        echo "xyz" "abc
                def
                ghi" &&
-       echo 'xyz' 'abc
-               def
-               ghi' &&
-       echo 'xyz' "abc
-               def
-               ghi" &&
        barfoo
 )
index 0ff136ab3cf1706b52f839686b259df0211d3914..0215cdb1921b5bf27c302ffdf4c48e5bf5a4848a 100644 (file)
@@ -7,7 +7,7 @@
                # minor numbers of cows (or do they?)
                baz &&
                snaff
-# LINT: missing "&&" on ')'
+# LINT: missing "&&" on ")"
        )
        fuzzy
 )
index e6af4de91672f9bb9736dc598ef49e3557672b3d..dd82534c6678624eb259c70d51f7a61fab603994 100644 (file)
@@ -4,7 +4,7 @@
        bar |
        baz &&
 
-# LINT: final line of pipe sequence ('cow') lacking "&&"
+# LINT: final line of pipe sequence ("cow") lacking "&&"
        fish |
        cow
 
index 74723e734043bd6300318b91a4874509c850460c..7e057aee420395d0876139211b46d6439e5e43e4 100644 (file)
@@ -5,7 +5,6 @@
 >) &&
 (
        cat >bup &&
-       cat >bup2 &&
        cat >bup3 &&
        meep
 >)
index 0cce907ba8d9757aa342404a4b2ba0cb3eb9eea5..d40eb65583f92f375dddbd3db76a893562724703 100644 (file)
@@ -8,7 +8,7 @@
        nevermore...
        EOF
 
-# LINT: missing "&&" on 'cat'
+# LINT: missing "&&" on "cat"
        cat <<EOF >bip
        fish fly high
 EOF
@@ -27,10 +27,6 @@ EOF
        glink
        FIZZ
        ARBITRARY
-       cat <<-'ARBITRARY2' >bup2 &&
-       glink
-       FIZZ
-       ARBITRARY2
        cat <<-"ARBITRARY3" >bup3 &&
        glink
        FIZZ
index c9913429e64b4d4c50318625832366dcf0007b64..f769244ef6426ac2dc459465f4dd520cbfb00bd6 100644 (file)
@@ -1,9 +1,9 @@
 (
        chks="sub1sub2sub3sub4" &&
-       chks_sub=$(cat | sed 's,^,sub dir/,'
+       chks_sub=$(cat | sed "s,^,sub dir/,"
 >>) &&
        chkms="main-sub1main-sub2main-sub3main-sub4" &&
-       chkms_sub=$(cat | sed 's,^,sub dir/,'
+       chkms_sub=$(cat | sed "s,^,sub dir/,"
 >>) &&
        subfiles=$(git ls-files) &&
        check_equal "$subfiles" "$chkms$chks"
index 277d8358dfd5f8d104665c420be234d40da9fb4e..02f3129232a0d114bf90211b9a6508385d0115bd 100644 (file)
@@ -3,7 +3,7 @@
 sub2
 sub3
 sub4" &&
-       chks_sub=$(cat <<TXT | sed 's,^,sub dir/,'
+       chks_sub=$(cat <<TXT | sed "s,^,sub dir/,"
 $chks
 TXT
 ) &&
@@ -11,7 +11,7 @@ TXT
 main-sub2
 main-sub3
 main-sub4" &&
-       chkms_sub=$(cat <<TXT | sed 's,^,sub dir/,'
+       chkms_sub=$(cat <<TXT | sed "s,^,sub dir/,"
 $chkms
 TXT
 ) &&
index f1df085bf03bf4b417b8231c35302328e27b4dbf..d09fb016e4405c5d9f7378b2ee5b9a634c4a9dc2 100644 (file)
@@ -1,17 +1,17 @@
 (
-# LINT: 'while, 'do', 'done' do not need "&&"
+# LINT: "while", "do", "done" do not need "&&"
        while true
        do
-# LINT: missing "&&" on 'echo'
+# LINT: missing "&&" on "echo"
                echo foo
 # LINT: last statement of while does not need "&&"
                cat <<-\EOF
                bar
                EOF
-# LINT: missing "&&" on 'done'
+# LINT: missing "&&" on "done"
        done
 
-# LINT: 'do' on same line as 'while'
+# LINT: "do" on same line as "while"
        while true; do
                echo foo &&
                cat bar