diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-05-08 10:24:09 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-05-08 11:01:18 +0300 |
commit | bad0209b1a9df569fddb99b22aae631860e32067 (patch) | |
tree | 117d29e6d5ef7ca74b813e20368a04fdee685d63 /templates | |
parent | faa2006cf9fadf4aa97e4e1db287fccbb099bed9 (diff) | |
download | subplot-bad0209b1a9df569fddb99b22aae631860e32067.tar.gz |
Refactor: bash template to put scenarios in functions
Diffstat (limited to 'templates')
-rw-r--r-- | templates/bash/template.sh | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/templates/bash/template.sh b/templates/bash/template.sh index 607c642..2466b69 100644 --- a/templates/bash/template.sh +++ b/templates/bash/template.sh @@ -166,25 +166,37 @@ files_set "$filename" "$contents" {% for scenario in scenarios %} ###################################### # Scenario: {{ scenario.title }} -title="$(decode_base64 '{{ scenario.title | base64 }}')" -echo "scenario: $title" -_scendir="$(mktemp -d -p "$_datadir")" -cd "$_scendir" -ctx_new -{% for step in scenario.steps %} -# Step: {{ step.text }} -step="$(decode_base64 '{{ step.text | base64 }}')" -echo " step: {{ step.kind | lower }} $step" - -cap_new -{% for part in step.parts %}{% if part.CapturedText is defined -%} -name="$(decode_base64 '{{ part.CapturedText.name | base64 }}')" -text="$(decode_base64 '{{ part.CapturedText.text | base64 }}')" -cap_set "$name" "$text" -{% endif -%} -{% endfor -%} -{{ step.function }} +scenario_{{ loop.index }}() { + local _title _scendir _step _name _text + + _title="$(decode_base64 '{{ scenario.title | base64 }}')" + echo "scenario: $_title" + + _scendir="$(mktemp -d -p "$_datadir")" + cd "$_scendir" + ctx_new + {% for step in scenario.steps %} + # Step: {{ step.text }} + _step="$(decode_base64 '{{ step.text | base64 }}')" + echo " step: {{ step.kind | lower }} $_step" + + cap_new + {% for part in step.parts %}{% if part.CapturedText is defined -%} + _name="$(decode_base64 '{{ part.CapturedText.name | base64 }}')" + _text="$(decode_base64 '{{ part.CapturedText.text | base64 }}')" + cap_set "$_name" "$_text" + {% endif -%} + {% endfor -%} + {{ step.function }} + {% endfor %} +} {% endfor %} + +############################################################################# +# Run the scenarios. + +{% for scenario in scenarios %} +scenario_{{ loop.index }} {% endfor %} |