mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Making --fail-not-set work with partials
The return code was not propagated through nested subshells in case when files were passed in as arguments.
This commit is contained in:
parent
50aa18e2a6
commit
2b611b8f90
9
mo
9
mo
@ -696,7 +696,7 @@ moParse() {
|
||||
# Returns nothing.
|
||||
moPartial() {
|
||||
# Namespace variables here to prevent conflicts.
|
||||
local moContent moFilename moIndent moPartial moStandalone
|
||||
local moContent moFilename moIndent moPartial moStandalone moUnindented
|
||||
|
||||
if moIsStandalone moStandalone "$2" "$4" "$5"; then
|
||||
moStandalone=( $moStandalone )
|
||||
@ -715,16 +715,17 @@ moPartial() {
|
||||
(
|
||||
# TODO: Remove dirname and use a function instead
|
||||
cd "$(dirname -- "$moFilename")" || exit 1
|
||||
moIndentLines moPartial "$moIndent" "$(
|
||||
moUnindented="$(
|
||||
moLoadFile moPartial "${moFilename##*/}"
|
||||
moParse "${moPartial}" "$6" true
|
||||
|
||||
# Fix bash handling of subshells and keep trailing whitespace.
|
||||
# This is removed in moIndentLines.
|
||||
echo -n "."
|
||||
)"
|
||||
)" || exit 1
|
||||
moIndentLines moPartial "$moIndent" "$moUnindented"
|
||||
echo -n "$moPartial"
|
||||
)
|
||||
) || exit 1
|
||||
|
||||
local "$1" && moIndirect "$1" "$moContent"
|
||||
}
|
||||
|
1
tests/fail-not-set-file.expected
Normal file
1
tests/fail-not-set-file.expected
Normal file
@ -0,0 +1 @@
|
||||
Env variable not set: __NO_SUCH_VAR
|
9
tests/fail-not-set-file.sh
Executable file
9
tests/fail-not-set-file.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "${0%/*}"
|
||||
unset __NO_SUCH_VAR
|
||||
../mo --fail-not-set ./fail-not-set-file.template 2>&1
|
||||
|
||||
if [[ $? -ne 1 ]]; then
|
||||
echo "Did not return 1"
|
||||
fi
|
1
tests/fail-not-set-file.template
Normal file
1
tests/fail-not-set-file.template
Normal file
@ -0,0 +1 @@
|
||||
* {{__NO_SUCH_VAR}}
|
Loading…
Reference in New Issue
Block a user