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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
32 lines
568 B
Plaintext
32 lines
568 B
Plaintext
test_expect_success 'if-then-else' '
|
|
(
|
|
# LINT: "if", "then", "elif", "else", "fi" do not need "&&"
|
|
if test -n ""
|
|
then
|
|
# LINT: missing "&&" on "echo"
|
|
echo very
|
|
# LINT: last statement before "elif" does not need "&&"
|
|
echo empty
|
|
elif test -z ""
|
|
then
|
|
# LINT: last statement before "else" does not need "&&"
|
|
echo foo
|
|
else
|
|
echo foo &&
|
|
# LINT: last statement before "fi" does not need "&&"
|
|
cat <<-\EOF
|
|
bar
|
|
EOF
|
|
# LINT: missing "&&" on "fi"
|
|
fi
|
|
echo poodle
|
|
) &&
|
|
(
|
|
# LINT: "then" on same line as "if"
|
|
if test -n ""; then
|
|
echo very &&
|
|
echo empty
|
|
fi
|
|
)
|
|
'
|