Skip to content

Commit 5459bc1

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 925d730 commit 5459bc1

20 files changed

+38
-70
lines changed

t/chainlint/broken-chain.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(
22
foo &&
3-
# LINT: missing "&&" from 'bar'
3+
# LINT: missing "&&" from "bar"
44
bar
55
baz &&
66
# LINT: final statement before closing ")" legitimately lacks "&&"

t/chainlint/case.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
(
2-
# LINT: "...)" arms in 'case' not misinterpreted as subshell-closing ")"
2+
# LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
33
case "$x" in
44
x) foo ;;
55
*) bar ;;
66
esac &&
77
foobar
88
) &&
99
(
10-
# LINT: missing "&&" on 'esac'
10+
# LINT: missing "&&" on "esac"
1111
case "$x" in
1212
x) foo ;;
1313
*) bar ;;
1414
esac
1515
foobar
1616
) &&
1717
(
18-
# LINT: "...)" arm in one-liner 'case' not misinterpreted as closing ")"
18+
# LINT: "...)" arm in one-liner "case" not misinterpreted as closing ")"
1919
case "$x" in 1) true;; esac &&
2020
# LINT: same but missing "&&"
2121
case "$y" in 2) false;; esac

t/chainlint/complex-if-in-cuddled-loop.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
22
# LINT: multi-line condition; indented with spaces, not tabs
33
(for i in a b c; do
44
if test "$(echo $(waffle bat))" = "eleventeen" &&

t/chainlint/cuddled-if-then-else.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
22
(if test -z ""; then
33
echo empty
44
else

t/chainlint/cuddled-loop.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LINT: 'while' loop cuddled with "(" and ")", with embedded (allowed)
1+
# LINT: "while" loop cuddled with "(" and ")", with embedded (allowed)
22
# LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
33
# LINT: loop; indented with spaces, not tabs
44
( while read x

t/chainlint/for-loop.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
(
2-
# LINT: 'for', 'do', 'done' do not need "&&"
2+
# LINT: "for", "do", "done" do not need "&&"
33
for i in a b c
44
do
5-
# LINT: missing "&&" on 'echo'
5+
# LINT: missing "&&" on "echo"
66
echo $i
77
# LINT: last statement of while does not need "&&"
88
cat <<-\EOF
99
bar
1010
EOF
11-
# LINT: missing "&&" on 'done'
11+
# LINT: missing "&&" on "done"
1212
done
1313

14-
# LINT: 'do' on same line as 'for'
14+
# LINT: "do" on same line as "for"
1515
for i in a b c; do
1616
echo $i &&
1717
cat $i

t/chainlint/here-doc.expect

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ boodle wobba gorgo snoot wafta snurb &&
22

33
cat >foo &&
44

5-
cat >bar &&
6-
75
cat >boo &&
86

97
horticulture

t/chainlint/here-doc.test

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ boz
1414
woz
1515
Arbitrary_Tag_42
1616

17-
# LINT: swallow 'quoted' here-doc
18-
cat <<'FUMP' >bar &&
19-
snoz
20-
boz
21-
woz
22-
FUMP
23-
2417
# LINT: swallow "quoted" here-doc
2518
cat <<"zump" >boo &&
2619
snoz

t/chainlint/if-in-loop.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
do
44
if false
55
then
6-
# LINT: missing "&&" on 'echo'
6+
# LINT: missing "&&" on "echo"
77
echo "err"
88
exit 1
9-
# LINT: missing "&&" on 'fi'
9+
# LINT: missing "&&" on "fi"
1010
fi
1111
foo
12-
# LINT: missing "&&" on 'done'
12+
# LINT: missing "&&" on "done"
1313
done
1414
bar
1515
)

t/chainlint/if-then-else.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
(
2-
# LINT: 'if', 'then', 'elif', 'else', 'fi' do not need "&&"
2+
# LINT: "if", "then", "elif", "else", "fi" do not need "&&"
33
if test -n ""
44
then
5-
# LINT: missing "&&" on 'echo'
5+
# LINT: missing "&&" on "echo"
66
echo very
7-
# LINT: last statement before 'elif' does not need "&&"
7+
# LINT: last statement before "elif" does not need "&&"
88
echo empty
99
elif test -z ""
1010
then
11-
# LINT: last statement before 'else' does not need "&&"
11+
# LINT: last statement before "else" does not need "&&"
1212
echo foo
1313
else
1414
echo foo &&
15-
# LINT: last statement before 'fi' does not need "&&"
15+
# LINT: last statement before "fi" does not need "&&"
1616
cat <<-\EOF
1717
bar
1818
EOF
19-
# LINT: missing "&&" on 'fi'
19+
# LINT: missing "&&" on "fi"
2020
fi
2121
echo poodle
2222
) &&
2323
(
24-
# LINT: 'then' on same line as 'if'
24+
# LINT: "then" on same line as "if"
2525
if test -n ""; then
2626
echo very &&
2727
echo empty

0 commit comments

Comments
 (0)