Add "mo" from "ssh://git@git.knownelement.com:29418/ExternalVendorCode/mo.git@master"
git-vendor-name: mo git-vendor-dir: vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo git-vendor-repository: ssh://git@git.knownelement.com:29418/ExternalVendorCode/mo.git git-vendor-ref: master
This commit is contained in:
		
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/ampersand
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/ampersand
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thing="Works" | ||||
| export template="{{&thing}}" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										21
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/array
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/array
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export repo=( "resque" "hub" "rip" ) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{#repo}} | ||||
|   <b>{{@key}} - {{.}}</b> | ||||
| {{/repo}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
|   <b>0 - resque</b> | ||||
|   <b>1 - hub</b> | ||||
|   <b>2 - rip</b> | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/assoc-array
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/assoc-array
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| declare -A repo | ||||
| # The order of the array elements can be shuffled depending on the version of | ||||
| # Bash. Keeping this to a minimal set and alphabetized seems to help. | ||||
| repo[hub]="Hub" | ||||
| repo[rip]="Rip" | ||||
| export repo | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{#repo}} | ||||
|   <b>{{@key}} - {{.}}</b> | ||||
| {{/repo}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
|   <b>hub - Hub</b> | ||||
|   <b>rip - Rip</b> | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export template="Wor{{!comment}}ks" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										15
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment-newline
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment-newline
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| template() { | ||||
|     cat <<EOF | ||||
| <h1>Today{{! ignore me | ||||
| and this can | ||||
| run through multiple | ||||
| lines}}.</h1> | ||||
| EOF | ||||
| } | ||||
| export expected=$'<h1>Today.</h1>\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment-with-spaces
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/comment-with-spaces
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export template="Wor{{! comment }}ks" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/concatenated-variables
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/concatenated-variables
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thing="Wor" | ||||
| export thing2="ks" | ||||
| export template="{{thing thing2}}" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/delimiters
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/delimiters
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thing="Works" | ||||
| export template="{{=| |=}}|thing|" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/double-hyphen
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/double-hyphen
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--fail-on-file -- --help) | ||||
| export returnCode=1 | ||||
| export template="" | ||||
| export expected=$'ERROR: No such file: --help\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/double-quote
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/double-quote
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export template='{{"Works"}}' | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										20
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fail-not-set
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fail-not-set
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| unset __NO_SUCH_VAR | ||||
| export POPULATED="words" | ||||
| export EMPTY="" | ||||
| export arguments=(--fail-not-set) | ||||
| export returnCode=1 | ||||
|  | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Populated: {{POPULATED}}; | ||||
| Empty: {{EMPTY}}; | ||||
| Unset: {{__NO_SUCH_VAR}}; | ||||
| EOF | ||||
| } | ||||
| export expected=$'ERROR: Environment variable not set: __NO_SUCH_VAR\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										13
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fail-on-function
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fail-on-function
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| failFunction() { | ||||
|     false | ||||
| } | ||||
| export arguments=(--fail-on-function) | ||||
| export returnCode=1 | ||||
| export template="Fail on function? {{failFunction}}" | ||||
| export expected=$'ERROR: Function failed with status code 1: "failFunction"\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-is-empty-arg
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-is-empty-arg
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export USER=j.doe | ||||
| export ADMIN=false | ||||
| export arguments=(--false) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| The user {{USER}} exists. | ||||
| {{#ADMIN}} | ||||
| WRONG - should not be an admin. | ||||
| {{/ADMIN}} | ||||
| EOF | ||||
| } | ||||
| export expected=$'The user j.doe exists.\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-is-empty-env
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-is-empty-env
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export USER=j.doe | ||||
| export ADMIN=false | ||||
| MO_FALSE_IS_EMPTY=yeppers | ||||
| template() { | ||||
|     cat <<EOF | ||||
| The user {{USER}} exists. | ||||
| {{#ADMIN}} | ||||
| WRONG - should not be an admin. | ||||
| {{/ADMIN}} | ||||
| EOF | ||||
| } | ||||
| export expected=$'The user j.doe exists.\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-list
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/false-list
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export person="" | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Shown. | ||||
| {{#person}} | ||||
|   Never shown! | ||||
| {{/person}} | ||||
| EOF | ||||
| } | ||||
| export expected=$'Shown.\n' | ||||
|  | ||||
| runTest | ||||
| @@ -0,0 +1,2 @@ | ||||
| first line | ||||
| second line | ||||
| @@ -0,0 +1,2 @@ | ||||
| > | ||||
| > | ||||
| @@ -0,0 +1 @@ | ||||
| {{multilineData}} | ||||
							
								
								
									
										1
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fixtures/partial.partial
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fixtures/partial.partial
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| <strong>{{.}}</strong> | ||||
| @@ -0,0 +1,2 @@ | ||||
| export A=from1 | ||||
| export B=from1 | ||||
| @@ -0,0 +1,2 @@ | ||||
| export B=from2 | ||||
| export C=from2 | ||||
							
								
								
									
										5
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fixtures/source.vars
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/fixtures/source.vars
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| export VAR=value | ||||
| export ARR=(1 2 3) | ||||
| declare -A ASSOC_ARR | ||||
| # Can not export associative arrays, otherwise they turn into indexed arrays | ||||
| ASSOC_ARR=([a]=AAA [b]=BBB) | ||||
| @@ -0,0 +1,3 @@ | ||||
| | | ||||
| {{content}} | ||||
| | | ||||
							
								
								
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export name=Willy | ||||
| wrapped() { | ||||
|     # Wrapping 'cat' in a subshell eats the trailing whitespace | ||||
|     # The echo adds a newline, which is preserved. | ||||
|     echo "<b>$(cat)</b>" | ||||
| } | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{#wrapped}} | ||||
|   {{name}} is awesome. | ||||
| {{/wrapped}} | ||||
| ... this is the last line. | ||||
| EOF | ||||
| } | ||||
|  | ||||
| # We don't expect {{name}} to be changed. The function returns whatever content | ||||
| # that should be the result. There is a separate test where the function handles | ||||
| # parsing mustache tags. | ||||
| export expected=$'<b>  {{name}} is awesome.</b>\n... this is the last line.\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-alternate-delimiters
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-alternate-delimiters
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export planet=Earth | ||||
| lambda() { | ||||
|     local content | ||||
|  | ||||
|     content=$(cat) | ||||
|     mo::parse content "$content{{planet}} => |planet|$content" | ||||
|     echo -n "$content" | ||||
| } | ||||
| export template="{{= | | =}}<|#lambda|-|/lambda|>" | ||||
| export expected="<-{{planet}} => Earth->" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										35
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-args
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										35
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-args
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export name=Willy | ||||
| MO_ALLOW_FUNCTION_ARGUMENTS=true | ||||
|  | ||||
| pipeTo() { | ||||
|     cat | "$1" | ||||
| } | ||||
|  | ||||
| testArgs() { | ||||
|     printf "%d" "$#" | ||||
|  | ||||
|     # Display all arguments | ||||
|     printf " %q" ${@+"$@"} | ||||
| } | ||||
| template() { | ||||
|     cat <<EOF | ||||
| No args: {{testArgs}} - done | ||||
| One arg: {{testArgs 'one'}} - done | ||||
| Getting name in a string: {{testArgs {"The name is " name}}} - done | ||||
| Reverse this: {{#pipeTo "rev"}}abcde{{/pipeTo "rev"}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| No args: 0 '' - done | ||||
| One arg: 1 one - done | ||||
| Getting name in a string: 1 The\ name\ is\ Willy - done | ||||
| Reverse this: edcba | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										42
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-args-read
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-args-read
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| testArgs() { | ||||
|     local args | ||||
|     # shellcheck disable=SC2031 | ||||
|     args=$(declare -p MO_FUNCTION_ARGS) | ||||
|  | ||||
|     # The output from declare -p could look like these | ||||
|     #     declare -a MO_FUNCTION_ARGS=([0]="one") | ||||
|     #     declare -ax MO_FUNCTION_ARGS='([0]="one")' | ||||
|     # Trim leading declare statement and variable name | ||||
|     args="${args#*=}" | ||||
|  | ||||
|     # If there are any quotes, remove them. The function arguments will always | ||||
|     # be an array. | ||||
|     if [[ "${args:0:1}" == "'" ]]; then | ||||
|         args=${args#\'} | ||||
|         args=${args%\'} | ||||
|     fi | ||||
|  | ||||
|     echo -n "$args" | ||||
| } | ||||
| template() { | ||||
|     cat <<EOF | ||||
| No args: {{testArgs}} - done | ||||
| One arg: {{testArgs 'one'}} - done | ||||
| Multiple arguments: {{testArgs 'aa' 'bb' 'cc' 'x' "" '!' '{[_.|' }} - done | ||||
| Evil: {{testArgs bla; cat /etc/issue}} - done | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| No args: () - done | ||||
| One arg: ([0]="one") - done | ||||
| Multiple arguments: ([0]="aa" [1]="bb" [2]="cc" [3]="x" [4]="" [5]="!" [6]="{[_.|") - done | ||||
| Evil: ([0]="" [1]="" [2]="") - done | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										28
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-with-more-parsing
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/function-with-more-parsing
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export name=Willy | ||||
| wrapped() { | ||||
|     local content | ||||
|  | ||||
|     # Wrapping 'cat' in a subshell eats the trailing whitespace | ||||
|     content="<b>$(cat)</b>" | ||||
|  | ||||
|     # Parse the content using mustache | ||||
|     mo::parse content "$content" | ||||
|  | ||||
|     # The echo adds a newline, which is preserved. | ||||
|     echo "$content" | ||||
| } | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{#wrapped}} | ||||
|   {{name}} is awesome. | ||||
| {{/wrapped}} | ||||
| ... this is the last line. | ||||
| EOF | ||||
| } | ||||
| export expected=$'<b>  Willy is awesome.</b>\n... this is the last line.\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										28
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/globals-in-loop
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/globals-in-loop
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export STR=abc | ||||
| export DATA=(111 222) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Issue #7 | ||||
| {{STR}} | ||||
| {{#DATA}} | ||||
|     Item: {{.}} | ||||
|     String: {{STR}} | ||||
| {{/DATA}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| Issue #7 | ||||
| abc | ||||
|     Item: 111 | ||||
|     String: abc | ||||
|     Item: 222 | ||||
|     String: abc | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										101
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/help
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										101
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/help
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--help) | ||||
| expected() { | ||||
|     cat <<'EOF' | ||||
| 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/ | ||||
|  | ||||
| Simple usage: | ||||
|  | ||||
|    mo [OPTIONS] filenames... | ||||
|  | ||||
| Options: | ||||
|  | ||||
|    --allow-function-arguments | ||||
|          Permit functions to be called with additional arguments. Otherwise, | ||||
|          the only way to get access to the arguments is to use the | ||||
|          MO_FUNCTION_ARGS environment variable. | ||||
|    -d, --debug | ||||
|          Enable debug logging to stderr. | ||||
|    -u, --fail-not-set | ||||
|          Fail upon expansion of an unset variable. Will silently ignore by | ||||
|          default. Alternately, set MO_FAIL_ON_UNSET to a non-empty value. | ||||
|    -x, --fail-on-function | ||||
|          Fail when a function returns a non-zero status code instead of | ||||
|          silently ignoring it. Alternately, set MO_FAIL_ON_FUNCTION to a | ||||
|          non-empty value. | ||||
|    -f, --fail-on-file | ||||
|          Fail when a file (from command-line or partial) does not exist. | ||||
|          Alternately, set MO_FAIL_ON_FILE to a non-empty value. | ||||
|    -e, --false | ||||
|          Treat the string "false" as empty for conditionals. Alternately, | ||||
|          set MO_FALSE_IS_EMPTY to a non-empty value. | ||||
|    -h, --help | ||||
|          This message. | ||||
|    -s=FILE, --source=FILE | ||||
|          Load FILE into the environment before processing templates. | ||||
|          Can be used multiple times. The file must be a valid shell script | ||||
|          and should only contain variable assignments. | ||||
|    -o=DELIM, --open=DELIM | ||||
|          Set the opening delimiter. Default is "{{". | ||||
|    -c=DELIM, --close=DELIM | ||||
|          Set the closing delimiter. Default is "}}". | ||||
|    --    Indicate the end of options. All arguments after this will be | ||||
|          treated as filenames only. Use when filenames may start with | ||||
|          hyphens. | ||||
|  | ||||
| Mo uses the following environment variables: | ||||
|  | ||||
| MO_ALLOW_FUNCTION_ARGUMENTS - When set to a non-empty value, this allows | ||||
|     functions referenced in templates to receive additional options and | ||||
|     arguments. | ||||
| MO_CLOSE_DELIMITER - The string used when closing a tag. Defaults to "}}". | ||||
|     Used internally. | ||||
| MO_CLOSE_DELIMITER_DEFAULT - The default value of MO_CLOSE_DELIMITER. Used | ||||
|     when resetting the close delimiter, such as when parsing a partial. | ||||
| MO_CURRENT - Variable name to use for ".". | ||||
| MO_DEBUG - When set to a non-empty value, additional debug information is | ||||
|     written to stderr. | ||||
| MO_FUNCTION_ARGS - Arguments passed to the function. | ||||
| MO_FAIL_ON_FILE - If a filename from the command-line is missing or a | ||||
|     partial does not exist, abort with an error. | ||||
| MO_FAIL_ON_FUNCTION - If a function returns a non-zero status code, abort | ||||
|     with an error. | ||||
| MO_FAIL_ON_UNSET - When set to a non-empty value, expansion of an unset env | ||||
|     variable will be aborted with an error. | ||||
| MO_FALSE_IS_EMPTY - When set to a non-empty value, the string "false" will | ||||
|     be treated as an empty value for the purposes of conditionals. | ||||
| MO_OPEN_DELIMITER - The string used when opening a tag. Defaults to "{{". | ||||
|     Used internally. | ||||
| MO_OPEN_DELIMITER_DEFAULT - The default value of MO_OPEN_DELIMITER. Used | ||||
|     when resetting the open delimiter, such as when parsing a partial. | ||||
| MO_ORIGINAL_COMMAND - Used to find the `mo` program in order to generate a | ||||
|     help message. | ||||
| MO_PARSED - Content that has made it through the template engine. | ||||
| MO_STANDALONE_CONTENT - The unparsed content that preceeded the current tag. | ||||
|     When a standalone tag is encountered, this is checked to see if it only | ||||
|     contains whitespace. If this and the whitespace condition after a tag is | ||||
|     met, then this will be reset to $'\n'. | ||||
| MO_UNPARSED - Template content yet to make it through the parser. | ||||
|  | ||||
| Mo is under a MIT style licence with an additional non-advertising clause. | ||||
| See LICENSE.md for the full text. | ||||
|  | ||||
| This is open source!  Please feel free to contribute. | ||||
|  | ||||
| https://github.com/tests-always-included/mo | ||||
|  | ||||
| MO_VERSION=3.0.7 | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										56
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/indented-partials
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										56
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/indented-partials
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thisIsTrue=true | ||||
| template() { | ||||
|     cat <<EOF | ||||
| With spacing | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|  | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|  | ||||
| Without spacing | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|  | ||||
| With text | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|     text | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
|  | ||||
| In a conditional | ||||
| {{#thisIsTrue}} | ||||
|     {{> fixtures/indented-partials.partial}} | ||||
| {{/thisIsTrue}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| With spacing | ||||
|     first line | ||||
|     second line | ||||
|  | ||||
|     first line | ||||
|     second line | ||||
|  | ||||
| Without spacing | ||||
|     first line | ||||
|     second line | ||||
|     first line | ||||
|     second line | ||||
|  | ||||
| With text | ||||
|     first line | ||||
|     second line | ||||
|     text | ||||
|     first line | ||||
|     second line | ||||
|  | ||||
| In a conditional | ||||
|     first line | ||||
|     second line | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										19
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/inline-indentation
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										19
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/inline-indentation
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export data="|" | ||||
| template() { | ||||
|     cat <<EOF | ||||
|   {{data}}  {{> fixtures/inline-indentation}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
|   |  > | ||||
| > | ||||
|  | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/internal-whitespace
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/internal-whitespace
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export boolean=true | ||||
| export template=$' | {{#boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n' | ||||
| export expected=$' |  \n  | \n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										11
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/invalid-option
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/invalid-option
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export person="" | ||||
| export template="" | ||||
| export returnCode=1 | ||||
| export arguments=(--something) | ||||
| export expected=$'ERROR: Unknown option: --something (See --help for options)\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/inverted
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/inverted
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export repo=() | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{#repo}} | ||||
|   <b>{{.}}</b> | ||||
| {{/repo}} | ||||
| {{^repo}} | ||||
|   No repos :( | ||||
| {{/repo}} | ||||
| EOF | ||||
| } | ||||
| export expected=$'  No repos :(\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/issue-75
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/issue-75
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export uv | ||||
| export template='{{^uv}}OK{{/uv}}{{#uv}}FAIL{{/uv}}' | ||||
| export expected='OK' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/list-contexts
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/list-contexts
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export a=foo | ||||
| export b=wrong | ||||
| declare -A sec | ||||
| sec=([b]="bar") | ||||
| export sec | ||||
| declare -A c | ||||
| c=([d]="baz") | ||||
| export c | ||||
| export template="{{#sec}}{{a}} {{b}} {{c.d}}{{/sec}}" | ||||
| export expected="foo bar baz" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										24
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/miss
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/miss
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export name="Chris" | ||||
| export company="<b>GitHub</b>" | ||||
| template() { | ||||
|     cat <<EOF | ||||
| * .{{name}}. | ||||
| * .{{age}}. | ||||
| * .{{company}}. | ||||
| * .{{{company}}}. | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| * .Chris. | ||||
| * .. | ||||
| * .<b>GitHub</b>. | ||||
| * .<b>GitHub</b>. | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										35
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/multi-line-partial
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										35
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/multi-line-partial
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export multilineData=$'line 1\nline 2' | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Partial: | ||||
|  | ||||
| {{> fixtures/multi-line-partial.partial}} | ||||
|  | ||||
| Indented: | ||||
|  | ||||
|     {{> fixtures/multi-line-partial.partial}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| Partial: | ||||
|  | ||||
| line 1 | ||||
| line 2 | ||||
|  | ||||
| Indented: | ||||
|  | ||||
|     line 1 | ||||
| line 2 | ||||
| EOF | ||||
|     # This one looks odd, but if you check the spec spec/specs/partials.yaml, | ||||
|     # name "Standalone Indentation" (mirrors "standalone-indentation" in | ||||
|     # tests/), then the spec clearly shows that the indentation is applied | ||||
|     # before rendering. | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										33
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/mush
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/mush
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export USER=jwerle | ||||
| export GENDER=male | ||||
| export THING=apple | ||||
| export COLOR=red | ||||
| export PERSON=tobi | ||||
| export ADJECTIVE=cool | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{! this is a comment }} | ||||
|  | ||||
| {{USER}} is {{GENDER}} | ||||
| {{THING}} is {{COLOR}} | ||||
| {{PERSON}} is {{ADJECTIVE}} | ||||
| {{USER}} is friends with {{PERSON}} | ||||
| {{var}} {{value}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
|  | ||||
| jwerle is male | ||||
| apple is red | ||||
| tobi is cool | ||||
| jwerle is friends with tobi | ||||
|   | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/no-content
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/no-content
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export template="Works" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										22
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export names=( "Tyler" "Abc" ) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| <h2>Names</h2> | ||||
| {{#names}} | ||||
|   {{> fixtures/partial.partial}} | ||||
| {{/names}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| <h2>Names</h2> | ||||
|   <strong>Tyler</strong> | ||||
|   <strong>Abc</strong> | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial-bad-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial-bad-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| # This file intentionally does not exist | ||||
| export template="{{>fixtures/partial-bad-file.partial}}" | ||||
| export expected="" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										19
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial-missing
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										19
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/partial-missing
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export returnCode=1 | ||||
| export arguments=(--fail-on-file) | ||||
| export person="" | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Won't be there: {{> fixtures/partial-missing.partial}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| ERROR: No such file: partial-missing.partial | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/single-quote
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/single-quote
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export template="{{'Works'}}" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/single-variable-replacement
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/single-variable-replacement
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thing="Works" | ||||
| export template="{{thing}}" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--source=fixtures/source.vars) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| {{VAR}} | ||||
| {{#ARR}} | ||||
| * {{.}} | ||||
| {{/ARR}} | ||||
| {{ASSOC_ARR.a}} {{ASSOC_ARR.b}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| value | ||||
| * 1 | ||||
| * 2 | ||||
| * 3 | ||||
| AAA BBB | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-bad-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-bad-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--source=invalid) | ||||
| export returnCode=1 | ||||
| export template="Do not display this" | ||||
| export expected=$'No such file: invalid\n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										21
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-multiple
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-multiple
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--source=fixtures/source-multiple-1.vars --source=fixtures/source-multiple-2.vars) | ||||
| template() { | ||||
|     cat <<EOF | ||||
| A: {{A}} | ||||
| B: {{B}} | ||||
| C: {{C}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| A: from1 | ||||
| B: from2 | ||||
| C: from2 | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-no-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/source-no-file
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export arguments=(--source=) | ||||
| export returnCode=1 | ||||
| export template="Do not display this" | ||||
| export expected=$'No such file: \n' | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										24
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/standalone-indentation
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/standalone-indentation
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export content=$'<\n->' | ||||
| template() { | ||||
|     cat <<'EOF' | ||||
| \ | ||||
|  {{>fixtures/standalone-indentation.partial}} | ||||
| / | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<'EOF' | ||||
| \ | ||||
|  | | ||||
|  < | ||||
| -> | ||||
|  | | ||||
| / | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/triple-brace
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/triple-brace
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export thing="Works" | ||||
| export template="{{{thing}}}" | ||||
| export expected="Works" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										26
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/typical
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/typical
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export NAME="Chris" | ||||
| export VALUE=10000 | ||||
| export TAXED_VALUE=6000 | ||||
| export IN_CA=true | ||||
| template() { | ||||
|     cat <<EOF | ||||
| Hello {{NAME}} | ||||
| You have just won {{VALUE}} dollars! | ||||
| {{#IN_CA}} | ||||
| Well, {{TAXED_VALUE}} dollars, after taxes. | ||||
| {{/IN_CA}} | ||||
| EOF | ||||
| } | ||||
| expected() { | ||||
|     cat <<EOF | ||||
| Hello Chris | ||||
| You have just won 10000 dollars! | ||||
| Well, 6000 dollars, after taxes. | ||||
| EOF | ||||
| } | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/unbound-variable
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/unbound-variable
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| declare -A a | ||||
| export a=() | ||||
| export template="o{{#a.b}}WRONG{{/a.b}}k" | ||||
| export expected="ok" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/variable
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/variable
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export foo=bar | ||||
| export template="{{#foo}}{{.}} is {{foo}}{{/foo}}" | ||||
| export expected="bar is bar" | ||||
|  | ||||
| runTest | ||||
							
								
								
									
										53
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/variable-braces-and-parenthesis
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										53
									
								
								vendor/git@git.knownelement.com/29418/ExternalVendorCode/mo/tests/variable-braces-and-parenthesis
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| #!/usr/bin/env bash | ||||
| cd "${0%/*}" || exit 1 | ||||
| . ../run-tests | ||||
|  | ||||
| export array=("wrong0" "item1" "wrong2") | ||||
| export index=1 | ||||
|  | ||||
| # Example #8 is weird because of how the variable name is parsed. Considering | ||||
| # it's an edge case when a user probably has a bug in a template, I think we're | ||||
| # good leaving it as-is until a bug report is filed. | ||||
|  | ||||
| template() { | ||||
|     cat <<'EOF' | ||||
| Starting point: | ||||
| 1 "{{ array.1 }}" = "item1" | ||||
|  | ||||
| Whole expression: | ||||
| 2 "{{ {'array.' index} }}" = "array.1" | ||||
| 3 "{{ ('array.' index) }}" = "item1" | ||||
|  | ||||
| Partial expression: | ||||
| 4 "{{ 'array.' {index} }}" = "array.1" | ||||
| 5 "{{ 'array.' (index) }}" = "array." | ||||
|  | ||||
| Combined: | ||||
| 6 "{{ {'array.' {index}} }}" = "array.1" | ||||
| 7 "{{ {'array.' (index)} }}" = "array." | ||||
| 8 "{{ ('array.' (index)) }}" = "wrong0,item1,wrong2" | ||||
| 9 "{{ ('array.' {index}) }}" = "item1" | ||||
| EOF | ||||
| } | ||||
|  | ||||
| expected() { | ||||
|     cat <<'EOF' | ||||
| Starting point: | ||||
| 1 "item1" = "item1" | ||||
|  | ||||
| Whole expression: | ||||
| 2 "array.1" = "array.1" | ||||
| 3 "item1" = "item1" | ||||
|  | ||||
| Partial expression: | ||||
| 4 "array.1" = "array.1" | ||||
| 5 "array." = "array." | ||||
|  | ||||
| Combined: | ||||
| 6 "array.1" = "array.1" | ||||
| 7 "array." = "array." | ||||
| 8 "wrong0,item1,wrong2" = "wrong0,item1,wrong2" | ||||
| 9 "item1" = "item1" | ||||
| EOF | ||||
| } | ||||
| runTest | ||||
		Reference in New Issue
	
	Block a user