new file mode 100644
@@ -0,0 +1,2 @@
+2 echo "we should find this" ?!AMP?!
+3 echo "even though our heredoc has its indent stripped"
new file mode 100644
@@ -0,0 +1,4 @@
+test_expect_success 'here-doc-body-indent' - <<-\EOT
+ echo "we should find this"
+ echo "even though our heredoc has its indent stripped"
+EOT
new file mode 100644
@@ -0,0 +1,7 @@
+2 echo "outer here-doc does not allow indented end-tag" ?!AMP?!
+3 cat >file <<-\EOF &&
+4 but this inner here-doc
+5 does allow indented EOF
+6 EOF
+7 echo "missing chain after" ?!AMP?!
+8 echo "but this line is OK because it's the end"
new file mode 100644
@@ -0,0 +1,9 @@
+test_expect_success 'here-doc-body-pathological' - <<\EOF
+ echo "outer here-doc does not allow indented end-tag"
+ cat >file <<-\EOF &&
+ but this inner here-doc
+ does allow indented EOF
+ EOF
+ echo "missing chain after"
+ echo "but this line is OK because it's the end"
+EOF
new file mode 100644
@@ -0,0 +1,7 @@
+2 echo "missing chain before" ?!AMP?!
+3 cat >file <<-\EOF &&
+4 inside inner here-doc
+5 these are not shell commands
+6 EOF
+7 echo "missing chain after" ?!AMP?!
+8 echo "but this line is OK because it's the end"
new file mode 100644
@@ -0,0 +1,9 @@
+test_expect_success 'here-doc-body' - <<\EOT
+ echo "missing chain before"
+ cat >file <<-\EOF &&
+ inside inner here-doc
+ these are not shell commands
+ EOF
+ echo "missing chain after"
+ echo "but this line is OK because it's the end"
+EOT
new file mode 100644
@@ -0,0 +1,2 @@
+8 echo "actual test commands" ?!AMP?!
+9 echo "that should be checked"
new file mode 100644
@@ -0,0 +1,10 @@
+# This is obviously a ridiculous thing to do, but we should be able
+# to handle two here-docs on the same line, and attribute them
+# correctly.
+test_expect_success "$(cat <<END_OF_PREREQS)" 'here-doc-double' - <<\EOT
+SOME
+PREREQS
+END_OF_PREREQS
+ echo "actual test commands"
+ echo "that should be checked"
+EOT
The chainlint.pl script recently learned about the upcoming: test_expect_success 'some test' - <<\EOT TEST_BODY EOT syntax, where TEST_BODY should be checked in the usual way. Let's make sure this works by adding a few tests. The "here-doc-body" file tests the basic syntax, including an embedded here-doc which we should still be able to recognize. Likewise the "here-doc-body-indent" checks the same thing, but using the "<<-" operator. We wouldn't expect this to be used normally, but we would not want to accidentally miss a body that uses it. The "pathological" variant checks the opposite: we don't get confused by an indented tag within the here-doc body. The "here-doc-double" tests the handling of two here-doc tags on the same line. This is not something we'd expect anybody to do in practice, but the code was written defensively to handle this, so let's make sure it works. Signed-off-by: Jeff King <peff@peff.net> --- t/chainlint/here-doc-body-indent.expect | 2 ++ t/chainlint/here-doc-body-indent.test | 4 ++++ t/chainlint/here-doc-body-pathological.expect | 7 +++++++ t/chainlint/here-doc-body-pathological.test | 9 +++++++++ t/chainlint/here-doc-body.expect | 7 +++++++ t/chainlint/here-doc-body.test | 9 +++++++++ t/chainlint/here-doc-double.expect | 2 ++ t/chainlint/here-doc-double.test | 10 ++++++++++ 8 files changed, 50 insertions(+) create mode 100644 t/chainlint/here-doc-body-indent.expect create mode 100644 t/chainlint/here-doc-body-indent.test create mode 100644 t/chainlint/here-doc-body-pathological.expect create mode 100644 t/chainlint/here-doc-body-pathological.test create mode 100644 t/chainlint/here-doc-body.expect create mode 100644 t/chainlint/here-doc-body.test create mode 100644 t/chainlint/here-doc-double.expect create mode 100644 t/chainlint/here-doc-double.test