Skip to content

Commit 1ad0780

Browse files
sunshinecogitster
authored andcommitted
t/chainlint/*.test: generalize self-test commentary
The purpose of chainlint.sed is to detect &&-chain breakage only within subshells (one level deep); it doesn't bother checking for top-level &&-chain breakage since the &&-chain checker built into t/test-lib.sh should detect broken &&-chains outside of subshells by making them magically exit with code 117. However, this division of labor may not always be the case if a more capable chainlint implementation is ever developed. Beyond that, due to being sed-based and due to its use of heuristics, chainlint.sed has several limitations (such as being unable to detect &&-chain breakage in subshells more than one level deep since it only manually emulates recursion into a subshell). Some of the comments in the chainlint self-tests unnecessarily reflect the limitations of chainlint.sed even though those limitations are not what is being tested. Therefore, simplify and generalize the comments to explain only what is being tested, thus ensuring that they won't become outdated if a more capable chainlint is ever developed. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5459bc1 commit 1ad0780

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

t/chainlint/blank-line.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
nothing &&
44

55
something
6-
# LINT: swallow blank lines since final _statement_ before subshell end is
6+
# LINT: ignore blank lines since final _statement_ before subshell end is
77
# LINT: significant to "&&"-check, not final _line_ (which might be blank)
88

99

t/chainlint/block.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(
2-
# LINT: missing "&&" in block not currently detected (for consistency with
3-
# LINT: --chain-lint at top level and to provide escape hatch if needed)
2+
# LINT: missing "&&" after first "echo"
43
foo &&
54
{
65
echo a

t/chainlint/cuddled.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# LINT: first subshell statement cuddled with opening "("; for implementation
2-
# LINT: simplicity, "(..." is split into two lines, "(" and "..."
1+
# LINT: first subshell statement cuddled with opening "("
32
(cd foo &&
43
bar
54
) &&

t/chainlint/nested-subshell.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
cd foo &&
99
(
10-
# LINT: nested multi-line subshell not presently checked for missing "&&"
1110
echo a
1211
echo b
1312
) >file

t/chainlint/one-liner.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(foo && bar) |
44
(foo && bar) >baz &&
55

6-
# LINT: top-level one-liner subshell missing internal "&&"
6+
# LINT: top-level one-liner subshell missing internal "&&" and broken &&-chain
77
(foo; bar) &&
88
(foo; bar) |
99
(foo; bar) >baz

t/chainlint/semicolon.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
cat foo; echo bar
1616
) &&
1717
(
18-
# LINT: unnecessary terminating semicolon
18+
# LINT: semicolon unnecessary but legitimate
1919
foo;
2020
) &&
2121
(cd foo &&
2222
for i in a b c; do
23-
# LINT: unnecessary terminating semicolon
23+
# LINT: semicolon unnecessary but legitimate
2424
echo;
2525
done)

0 commit comments

Comments
 (0)