From 600f5c5725f0fcdebc79e5572b62af887f10cd81 Mon Sep 17 00:00:00 2001 From: Tyler Akins Date: Thu, 21 Jul 2016 07:06:39 -0500 Subject: [PATCH] Adding mechanism to test command-line variables --- run-tests | 13 ++++++++++--- tests/help.expected | 8 ++++++++ tests/help.sh | 4 ++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/help.expected create mode 100755 tests/help.sh diff --git a/run-tests b/run-tests index 90ac4d4..69df382 100755 --- a/run-tests +++ b/run-tests @@ -10,9 +10,16 @@ for TEST in tests/*.expected; do BASE="${TEST%.expected}" echo -n "$BASE ... " - echo "Do not read this input" | ( - . "${BASE}.env" - mo "${BASE}.template" + + ( + if [[ -f "${BASE}.sh" ]]; then + # Run a shell script if one exists + "${BASE}.sh" + else + # Fall back to using .env and .template + . "${BASE}.env" + echo "Do not read this input" | mo "${BASE}.template" + fi ) | diff -wU5 - "${TEST}" > "${BASE}.diff" if [[ $? -ne 0 ]]; then diff --git a/tests/help.expected b/tests/help.expected new file mode 100644 index 0000000..c0cfa7f --- /dev/null +++ b/tests/help.expected @@ -0,0 +1,8 @@ +Mo is a mustache template rendering software written in bash. It inserts +environment variables into templates. + +Simply put, mo will change {{VARIABLE}} into the value of that +environment variable. You can use {{#VARIABLE}}content{{/VARIABLE}} to +conditionally display content or iterate over the values of an array. + +Learn more about mustache templates at https://mustache.github.io/ diff --git a/tests/help.sh b/tests/help.sh new file mode 100755 index 0000000..6e0a88c --- /dev/null +++ b/tests/help.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +cd "${0%/*}" +../mo --help