summaryrefslogtreecommitdiff
path: root/t/chainlint/subshell-here-doc.test
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2018-07-11 06:46:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-17 16:15:14 (GMT)
commit7b9067901260ece0274976a7fc39e84796ceb852 (patch)
tree1fc247066db31330269ad91deecb859dc28d8a3b /t/chainlint/subshell-here-doc.test
parent5238710eb404cc81de511743811f92759cb7ca7b (diff)
downloadgit-7b9067901260ece0274976a7fc39e84796ceb852.zip
git-7b9067901260ece0274976a7fc39e84796ceb852.tar.gz
git-7b9067901260ece0274976a7fc39e84796ceb852.tar.bz2
t/chainlint: add chainlint "whitespace" test cases
The --chain-lint option uses heuristics and knowledge of shell syntax to detect broken &&-chains in subshells by pure textual inspection. The heuristics handle a range of stylistic variations in existing tests (evolved over the years), however, they are still best-guesses. As such, it is possible for future changes to accidentally break assumptions upon which the heuristics are based. Protect against this possibility by adding tests which check the linter itself for correctness. In addition to protecting against regressions, these tests help document (for humans) expected behavior, which is important since the linter's implementation language ('sed') does not necessarily lend itself to easy comprehension. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/chainlint/subshell-here-doc.test')
-rw-r--r--t/chainlint/subshell-here-doc.test23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/chainlint/subshell-here-doc.test b/t/chainlint/subshell-here-doc.test
new file mode 100644
index 0000000..9c3564c
--- /dev/null
+++ b/t/chainlint/subshell-here-doc.test
@@ -0,0 +1,23 @@
+(
+# LINT: stitch together incomplete \-ending lines
+# LINT: swallow here-doc to avoid false positives in content
+ echo wobba \
+ gorgo snoot \
+ wafta snurb <<-EOF &&
+ quoth the raven,
+ nevermore...
+ EOF
+
+# LINT: missing "&&" on 'cat'
+ cat <<EOF >bip
+ fish fly high
+ EOF
+
+# LINT: swallow here-doc (EOF is last line of subshell)
+ echo <<-\EOF >bop
+ gomez
+ morticia
+ wednesday
+ pugsly
+ EOF
+)