t/chainlint/*.test: fix invalid test cases due to mixing quote types

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>

Eric Sunshine committed Dec 13, 2021 at 01:30 UTC 5459bc1bbb54536df18b034afd390f899bda37be
20 files changed +38 -70
t/chainlint/broken-chain.test
+1 -1
@@ -1,6 +1,6 @@
1 (
2 foo &&
3 -# LINT: missing "&&" from 'bar'
3 +# LINT: missing "&&" from "bar"
4 bar
5 baz &&
6 # LINT: final statement before closing ")" legitimately lacks "&&"
t/chainlint/case.test
+3 -3
@@ -1,5 +1,5 @@
1 (
2 -# LINT: "...)" arms in 'case' not misinterpreted as subshell-closing ")"
2 +# LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
3 case "$x" in
4 x) foo ;;
5 *) bar ;;
@@ -7,7 +7,7 @@
7 foobar
8 ) &&
9 (
10 -# LINT: missing "&&" on 'esac'
10 +# LINT: missing "&&" on "esac"
11 case "$x" in
12 x) foo ;;
13 *) bar ;;
@@ -15,7 +15,7 @@
15 foobar
16 ) &&
17 (
18 -# LINT: "...)" arm in one-liner 'case' not misinterpreted as closing ")"
18 +# LINT: "...)" arm in one-liner "case" not misinterpreted as closing ")"
19 case "$x" in 1) true;; esac &&
20 # LINT: same but missing "&&"
21 case "$y" in 2) false;; esac
t/chainlint/complex-if-in-cuddled-loop.test
+1 -1
@@ -1,4 +1,4 @@
1 -# LINT: 'for' loop cuddled with "(" and ")" and nested 'if' with complex
1 +# LINT: "for" loop cuddled with "(" and ")" and nested "if" with complex
2 # LINT: multi-line condition; indented with spaces, not tabs
3 (for i in a b c; do
4 if test "$(echo $(waffle bat))" = "eleventeen" &&
t/chainlint/cuddled-if-then-else.test
+1 -1
@@ -1,4 +1,4 @@
1 -# LINT: 'if' cuddled with "(" and ")"; indented with spaces, not tabs
1 +# LINT: "if" cuddled with "(" and ")"; indented with spaces, not tabs
2 (if test -z ""; then
3 echo empty
4 else
t/chainlint/cuddled-loop.test
+1 -1
@@ -1,4 +1,4 @@
1 -# LINT: 'while' loop cuddled with "(" and ")", with embedded (allowed)
1 +# LINT: "while" loop cuddled with "(" and ")", with embedded (allowed)
2 # LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
3 # LINT: loop; indented with spaces, not tabs
4 ( while read x
t/chainlint/for-loop.test
+4 -4
@@ -1,17 +1,17 @@
1 (
2 -# LINT: 'for', 'do', 'done' do not need "&&"
2 +# LINT: "for", "do", "done" do not need "&&"
3 for i in a b c
4 do
5 -# LINT: missing "&&" on 'echo'
5 +# LINT: missing "&&" on "echo"
6 echo $i
7 # LINT: last statement of while does not need "&&"
8 cat <<-\EOF
9 bar
10 EOF
11 -# LINT: missing "&&" on 'done'
11 +# LINT: missing "&&" on "done"
12 done
13
14 -# LINT: 'do' on same line as 'for'
14 +# LINT: "do" on same line as "for"
15 for i in a b c; do
16 echo $i &&
17 cat $i
t/chainlint/here-doc.expect
-2
@@ -2,8 +2,6 @@ boodle wobba gorgo snoot wafta snurb &&
2
3 cat >foo &&
4
5 -cat >bar &&
6 -
5 cat >boo &&
6
7 horticulture
t/chainlint/here-doc.test
-7
@@ -14,13 +14,6 @@ boz
14 woz
15 Arbitrary_Tag_42
16
17 -# LINT: swallow 'quoted' here-doc
18 -cat <<'FUMP' >bar &&
19 -snoz
20 -boz
21 -woz
22 -FUMP
23 -
17 # LINT: swallow "quoted" here-doc
18 cat <<"zump" >boo &&
19 snoz
t/chainlint/if-in-loop.test
+3 -3
@@ -3,13 +3,13 @@
3 do
4 if false
5 then
6 -# LINT: missing "&&" on 'echo'
6 +# LINT: missing "&&" on "echo"
7 echo "err"
8 exit 1
9 -# LINT: missing "&&" on 'fi'
9 +# LINT: missing "&&" on "fi"
10 fi
11 foo
12 -# LINT: missing "&&" on 'done'
12 +# LINT: missing "&&" on "done"
13 done
14 bar
15 )
t/chainlint/if-then-else.test
+7 -7
@@ -1,27 +1,27 @@
1 (
2 -# LINT: 'if', 'then', 'elif', 'else', 'fi' do not need "&&"
2 +# LINT: "if", "then", "elif", "else", "fi" do not need "&&"
3 if test -n ""
4 then
5 -# LINT: missing "&&" on 'echo'
5 +# LINT: missing "&&" on "echo"
6 echo very
7 -# LINT: last statement before 'elif' does not need "&&"
7 +# LINT: last statement before "elif" does not need "&&"
8 echo empty
9 elif test -z ""
10 then
11 -# LINT: last statement before 'else' does not need "&&"
11 +# LINT: last statement before "else" does not need "&&"
12 echo foo
13 else
14 echo foo &&
15 -# LINT: last statement before 'fi' does not need "&&"
15 +# LINT: last statement before "fi" does not need "&&"
16 cat <<-\EOF
17 bar
18 EOF
19 -# LINT: missing "&&" on 'fi'
19 +# LINT: missing "&&" on "fi"
20 fi
21 echo poodle
22 ) &&
23 (
24 -# LINT: 'then' on same line as 'if'
24 +# LINT: "then" on same line as "if"
25 if test -n ""; then
26 echo very &&
27 echo empty
t/chainlint/loop-in-if.test
+3 -3
@@ -3,13 +3,13 @@
3 then
4 while true
5 do
6 -# LINT: missing "&&" on 'echo'
6 +# LINT: missing "&&" on "echo"
7 echo "pop"
8 echo "glup"
9 -# LINT: missing "&&" on 'done'
9 +# LINT: missing "&&" on "done"
10 done
11 foo
12 -# LINT: missing "&&" on 'fi'
12 +# LINT: missing "&&" on "fi"
13 fi
14 bar
15 )
t/chainlint/multi-line-string.expect
+1 -7
@@ -1,15 +1,9 @@
1 (
2 x="line 1 line 2 line 3" &&
3 -?!AMP?! y='line 1 line2'
3 +?!AMP?! y="line 1 line2"
4 foobar
5 >) &&
6 -(
7 - echo "there's nothing to see here" &&
8 - exit
9 ->) &&
6 (
7 echo "xyz" "abc def ghi" &&
12 - echo 'xyz' 'abc def ghi' &&
13 - echo 'xyz' "abc def ghi" &&
8 barfoo
9 >)
t/chainlint/multi-line-string.test
+2 -14
@@ -3,25 +3,13 @@
3 line 2
4 line 3" &&
5 # LINT: missing "&&" on assignment
6 - y='line 1
7 - line2'
6 + y="line 1
7 + line2"
8 foobar
9 ) &&
10 -(
11 -# LINT: apostrophe (in a contraction) within string not misinterpreted as
12 -# LINT: starting multi-line single-quoted string
13 - echo "there's nothing to see here" &&
14 - exit
15 -) &&
10 (
11 echo "xyz" "abc
12 def
13 ghi" &&
20 - echo 'xyz' 'abc
21 - def
22 - ghi' &&
23 - echo 'xyz' "abc
24 - def
25 - ghi" &&
14 barfoo
15 )
t/chainlint/nested-subshell-comment.test
+1 -1
@@ -7,7 +7,7 @@
7 # minor numbers of cows (or do they?)
8 baz &&
9 snaff
10 -# LINT: missing "&&" on ')'
10 +# LINT: missing "&&" on ")"
11 )
12 fuzzy
13 )
t/chainlint/pipe.test
+1 -1
@@ -4,7 +4,7 @@
4 bar |
5 baz &&
6
7 -# LINT: final line of pipe sequence ('cow') lacking "&&"
7 +# LINT: final line of pipe sequence ("cow") lacking "&&"
8 fish |
9 cow
10
t/chainlint/subshell-here-doc.expect
-1
@@ -5,7 +5,6 @@
5 >) &&
6 (
7 cat >bup &&
8 - cat >bup2 &&
8 cat >bup3 &&
9 meep
10 >)
t/chainlint/subshell-here-doc.test
+1 -5
@@ -8,7 +8,7 @@
8 nevermore...
9 EOF
10
11 -# LINT: missing "&&" on 'cat'
11 +# LINT: missing "&&" on "cat"
12 cat <<EOF >bip
13 fish fly high
14 EOF
@@ -27,10 +27,6 @@ EOF
27 glink
28 FIZZ
29 ARBITRARY
30 - cat <<-'ARBITRARY2' >bup2 &&
31 - glink
32 - FIZZ
33 - ARBITRARY2
30 cat <<-"ARBITRARY3" >bup3 &&
31 glink
32 FIZZ
t/chainlint/t7900-subtree.expect
+2 -2
@@ -1,9 +1,9 @@
1 (
2 chks="sub1sub2sub3sub4" &&
3 - chks_sub=$(cat | sed 's,^,sub dir/,'
3 + chks_sub=$(cat | sed "s,^,sub dir/,"
4 >>) &&
5 chkms="main-sub1main-sub2main-sub3main-sub4" &&
6 - chkms_sub=$(cat | sed 's,^,sub dir/,'
6 + chkms_sub=$(cat | sed "s,^,sub dir/,"
7 >>) &&
8 subfiles=$(git ls-files) &&
9 check_equal "$subfiles" "$chkms$chks"
t/chainlint/t7900-subtree.test
+2 -2
@@ -3,7 +3,7 @@
3 sub2
4 sub3
5 sub4" &&
6 - chks_sub=$(cat <<TXT | sed 's,^,sub dir/,'
6 + chks_sub=$(cat <<TXT | sed "s,^,sub dir/,"
7 $chks
8 TXT
9 ) &&
@@ -11,7 +11,7 @@ TXT
11 main-sub2
12 main-sub3
13 main-sub4" &&
14 - chkms_sub=$(cat <<TXT | sed 's,^,sub dir/,'
14 + chkms_sub=$(cat <<TXT | sed "s,^,sub dir/,"
15 $chkms
16 TXT
17 ) &&
t/chainlint/while-loop.test
+4 -4
@@ -1,17 +1,17 @@
1 (
2 -# LINT: 'while, 'do', 'done' do not need "&&"
2 +# LINT: "while", "do", "done" do not need "&&"
3 while true
4 do
5 -# LINT: missing "&&" on 'echo'
5 +# LINT: missing "&&" on "echo"
6 echo foo
7 # LINT: last statement of while does not need "&&"
8 cat <<-\EOF
9 bar
10 EOF
11 -# LINT: missing "&&" on 'done'
11 +# LINT: missing "&&" on "done"
12 done
13
14 -# LINT: 'do' on same line as 'while'
14 +# LINT: "do" on same line as "while"
15 while true; do
16 echo foo &&
17 cat bar