Skip to content

Commit a5e4501

Browse files
peffgitster
authored andcommitted
chainlint.pl: add test_expect_success call to test snippets
The chainlint tests are a series of individual files, each holding a test body. The "make check-chainlint" target assembles them into a single file, adding a "test_expect_success" function call around each. Let's instead include that function call in the files themselves. This is a little more boilerplate, but has several advantages: 1. You can now run chainlint manually on snippets with just "perl chainlint.perl chainlint/foo.test". This can make developing and debugging a little easier. 2. Many of the tests implicitly relied on the syntax of the lines added by the Makefile (in particular the use of single-quotes). This assumption is much easier to see when the single-quotes are alongside the test body. 3. We had no way to test how the chainlint program handled various test_expect_success lines themselves. Now we'll be able to check variations. The change to the .test files was done mechanically, using the same test names they would have been assigned by the Makefile (this is important to match the expected output). The Makefile has the minimal change to drop the extra lines; there are more cleanups possible but a future patch in this series will rewrite this substantially anyway. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 790a17f commit a5e4501

File tree

73 files changed

+145
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+145
-3
lines changed

t/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ clean-chainlint:
109109
check-chainlint:
110110
@mkdir -p '$(CHAINLINTTMP_SQ)' && \
111111
for i in $(CHAINLINTTESTS); do \
112-
echo "test_expect_success '$$i' '" && \
113-
sed -e '/^# LINT: /d' chainlint/$$i.test && \
114-
echo "'"; \
112+
sed -e '/^# LINT: /d' chainlint/$$i.test; \
115113
done >'$(CHAINLINTTMP_SQ)'/tests && \
116114
{ \
117115
echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \

t/chainlint/arithmetic-expansion.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'arithmetic-expansion' '
12
(
23
foo &&
34
# LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")"
@@ -9,3 +10,4 @@
910
bar=$((42 + 1))
1011
baz
1112
)
13+
'

t/chainlint/bash-array.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'bash-array' '
12
(
23
foo &&
34
# LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")"
@@ -10,3 +11,4 @@
1011
bar=${#bar[@]} &&
1112
baz
1213
)
14+
'

t/chainlint/blank-line-before-esac.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'blank-line-before-esac' '
12
# LINT: blank line before "esac"
23
test_done () {
34
case "$test_failure" in
@@ -17,3 +18,4 @@ test_done () {
1718

1819
esac
1920
}
21+
'

t/chainlint/blank-line.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'blank-line' '
12
(
23

34
nothing &&
@@ -8,3 +9,4 @@
89

910

1011
)
12+
'

t/chainlint/block-comment.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'block-comment' '
12
(
23
{
34
# show a
@@ -6,3 +7,4 @@
67
echo b
78
}
89
)
10+
'

t/chainlint/block.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'block' '
12
(
23
# LINT: missing "&&" after first "echo"
34
foo &&
@@ -25,3 +26,4 @@
2526
echo "done"
2627
} &&
2728
finis
29+
'

t/chainlint/broken-chain.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'broken-chain' '
12
(
23
foo &&
34
# LINT: missing "&&" from "bar"
@@ -6,3 +7,4 @@
67
# LINT: final statement before closing ")" legitimately lacks "&&"
78
wop
89
)
10+
'

t/chainlint/case-comment.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'case-comment' '
12
(
23
case "$x" in
34
# found foo
@@ -9,3 +10,4 @@
910
;;
1011
esac
1112
)
13+
'

t/chainlint/case.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
test_expect_success 'case' '
12
(
23
# LINT: "...)" arms in "case" not misinterpreted as subshell-closing ")"
34
case "$x" in
@@ -21,3 +22,4 @@
2122
case "$y" in 2) false;; esac
2223
foobar
2324
)
25+
'

0 commit comments

Comments
 (0)