From 0627cbbaf8201e1e6be7d087c58a005559bf75ea Mon Sep 17 00:00:00 2001 From: Tyler Akins Date: Wed, 2 Aug 2017 10:35:35 -0500 Subject: [PATCH] Making tests care about whitespace When testing #19 I found that the tests were mistakenly ignoring some whitespace changes. I've enabled whitespace checks and had to update the tests because my editor likes newlines at the end of files and removes whitespace at the end of lines. To make the test files easier to manage, I've modified some scenarios to still test for the feature but also work with the whitespace modifications that editors would perform. --- run-tests | 2 +- tests/function.env | 3 ++- tests/function.expected | 2 +- tests/function.template | 1 + tests/miss.expected | 8 ++++---- tests/miss.template | 8 ++++---- tests/multi-line-partial.env | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/run-tests b/run-tests index 5a5df02..3a74fe2 100755 --- a/run-tests +++ b/run-tests @@ -21,7 +21,7 @@ for TEST in tests/*.expected; do . "${BASE}.env" echo "Do not read this input" | mo "${BASE}.template" fi - ) | diff -wU5 - "${TEST}" > "${BASE}.diff" + ) | diff -U5 - "${TEST}" > "${BASE}.diff" if [[ $? -ne 0 ]]; then echo "FAIL" diff --git a/tests/function.env b/tests/function.env index 64b0225..d96edf9 100644 --- a/tests/function.env +++ b/tests/function.env @@ -1,4 +1,5 @@ name=Willy wrapped() { - echo "$1"; + # The final newline is eaten by mo + echo "$1" } diff --git a/tests/function.expected b/tests/function.expected index a55e97c..1f1a461 100644 --- a/tests/function.expected +++ b/tests/function.expected @@ -1,2 +1,2 @@ Willy is awesome. - +... this is the last line. diff --git a/tests/function.template b/tests/function.template index b069eb7..91a2d9e 100644 --- a/tests/function.template +++ b/tests/function.template @@ -1,3 +1,4 @@ {{#wrapped}} {{name}} is awesome. {{/wrapped}} +... this is the last line. diff --git a/tests/miss.expected b/tests/miss.expected index eae407e..271627a 100644 --- a/tests/miss.expected +++ b/tests/miss.expected @@ -1,4 +1,4 @@ -* Chris -* -* GitHub -* GitHub +* .Chris. +* .. +* .GitHub. +* .GitHub. diff --git a/tests/miss.template b/tests/miss.template index d278abe..beaafee 100644 --- a/tests/miss.template +++ b/tests/miss.template @@ -1,4 +1,4 @@ -* {{name}} -* {{age}} -* {{company}} -* {{{company}}} +* .{{name}}. +* .{{age}}. +* .{{company}}. +* .{{{company}}}. diff --git a/tests/multi-line-partial.env b/tests/multi-line-partial.env index 3a1b584..3cd24fd 100644 --- a/tests/multi-line-partial.env +++ b/tests/multi-line-partial.env @@ -1 +1 @@ -multilineData=$'line 1\nline2' +multilineData=$'line 1\nline 2'