Skip to content

Commit

Permalink
added functional tests to check dealing with optional configs set by …
Browse files Browse the repository at this point in the history
…ENV or rose-suite.conf:opts=
  • Loading branch information
wxtim committed Nov 13, 2020
1 parent 8c83a1f commit 771c256
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/functional/rose-conf/04-opts-set-from-env.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test jinja2 from rose-suite.conf file is processed into a suite.
. "$(dirname "$0")/test_header"
#-------------------------------------------------------------------------------
set_test_number 1
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

export ROSE_SUITE_OPT_CONF_KEYS=Gaelige

cylc view -p --stdout "${SUITE_NAME}" > processed.conf.test

cmp_ok processed.conf.test processed.conf.control

purge
exit
36 changes: 36 additions & 0 deletions tests/functional/rose-conf/04-opts-set-from-env/flow.cylc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!jinja2
[meta]
title = "Add jinja2 vars from a rose-suite.conf"
description = """
Natively, in Cylc!
"""

[scheduling]
initial cycle point = {{ICP}}
final cycle point = {{FCP}}
cycling mode = integer
[[graph]]
{% for member in MEMBERS %}
P1 = {{TASK1}} => {{TASK2}}_{{member}} => {{TASK3}}
{% endfor %}
{% for key, value in SAMUELJOHNSON.items() %}
P1 = {{TASK3}} => {{value}}_auf_deutsch_ist_{{key}} => fin
{% endfor %}

[runtime]
[[root]]
script = echo "This task is ${CYLC_TASK_ID}"

[[{{ TASK1 }}]]

{% for member in MEMBERS %}
[[{{ TASK2 }}_{{member}}]]
{% endfor %}

[[{{ TASK3 }}]]

{% for key, value in SAMUELJOHNSON.items() %}
[[{{value}}_auf_deutsch_ist_{{key}}]]
{% endfor %}

[[fin]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="mynd"
TASK2="bwyta"
TASK3="prynu"
MEMBERS=["control", "un", "dau", "tri"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="cuir" # to put
TASK2="tog" # to lift
TASK3="gabh" # to take
MEMBERS=["control", "aon", "dhà", "trì"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[meta]
title = "Add jinja2 vars from a rose-suite.conf"
description = """
Natively, in Cylc!
"""
[scheduling]
initial cycle point = 1
final cycle point = 1
cycling mode = integer
[[graph]]
P1 = cuir => tog_control => gabh
P1 = cuir => tog_aon => gabh
P1 = cuir => tog_dhà => gabh
P1 = cuir => tog_trì => gabh
P1 = gabh => 1_auf_deutsch_ist_ein => fin
P1 = gabh => 2_auf_deutsch_ist_zwei => fin
P1 = gabh => 3_auf_deutsch_ist_drei => fin
[runtime]
[[root]]
script = echo "This task is ${CYLC_TASK_ID}"
[[cuir]]
[[tog_control]]
[[tog_aon]]
[[tog_dhà]]
[[tog_trì]]
[[gabh]]
[[1_auf_deutsch_ist_ein]]
[[2_auf_deutsch_ist_zwei]]
[[3_auf_deutsch_ist_drei]]
[[fin]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="respond"
TASK2="plunge"
TASK3="allow"
MEMBERS=["control", "yan", "tan", "tethera"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}
31 changes: 31 additions & 0 deletions tests/functional/rose-conf/05-opts-set-from-rose-suite.conf.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test jinja2 from rose-suite.conf file is processed into a suite.
. "$(dirname "$0")/test_header"
#-------------------------------------------------------------------------------
set_test_number 1
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

export ROSE_SUITE_OPT_CONF_KEYS=""

cylc view -p --stdout "${SUITE_NAME}" > processed.conf.test

cmp_ok processed.conf.test processed.conf.control

purge
exit
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!jinja2
[meta]
title = "Add jinja2 vars from a rose-suite.conf"
description = """
Natively, in Cylc!
"""

[scheduling]
initial cycle point = {{ICP}}
final cycle point = {{FCP}}
cycling mode = integer
[[graph]]
{% for member in MEMBERS %}
P1 = {{TASK1}} => {{TASK2}}_{{member}} => {{TASK3}}
{% endfor %}
{% for key, value in SAMUELJOHNSON.items() %}
P1 = {{TASK3}} => {{value}}_auf_deutsch_ist_{{key}} => fin
{% endfor %}

[runtime]
[[root]]
script = echo "This task is ${CYLC_TASK_ID}"

[[{{ TASK1 }}]]

{% for member in MEMBERS %}
[[{{ TASK2 }}_{{member}}]]
{% endfor %}

[[{{ TASK3 }}]]

{% for key, value in SAMUELJOHNSON.items() %}
[[{{value}}_auf_deutsch_ist_{{key}}]]
{% endfor %}

[[fin]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="mynd"
TASK2="bwyta"
TASK3="prynu"
MEMBERS=["control", "un", "dau", "tri"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="cuir" # to put
TASK2="tog" # to lift
TASK3="gabh" # to take
MEMBERS=["control", "aon", "dhà", "trì"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[meta]
title = "Add jinja2 vars from a rose-suite.conf"
description = """
Natively, in Cylc!
"""
[scheduling]
initial cycle point = 1
final cycle point = 1
cycling mode = integer
[[graph]]
P1 = mynd => bwyta_control => prynu
P1 = mynd => bwyta_un => prynu
P1 = mynd => bwyta_dau => prynu
P1 = mynd => bwyta_tri => prynu
P1 = prynu => 1_auf_deutsch_ist_ein => fin
P1 = prynu => 2_auf_deutsch_ist_zwei => fin
P1 = prynu => 3_auf_deutsch_ist_drei => fin
[runtime]
[[root]]
script = echo "This task is ${CYLC_TASK_ID}"
[[mynd]]
[[bwyta_control]]
[[bwyta_un]]
[[bwyta_dau]]
[[bwyta_tri]]
[[prynu]]
[[1_auf_deutsch_ist_ein]]
[[2_auf_deutsch_ist_zwei]]
[[3_auf_deutsch_ist_drei]]
[[fin]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
opts=Cymraeg
[jinja2:suite.rc]
ICP=1
FCP=1
TASK1="respond"
TASK2="plunge"
TASK3="allow"
MEMBERS=["control", "yan", "tan", "tethera"]
SAMUELJOHNSON={"ein": 1, "zwei": 2, "drei": 3}

0 comments on commit 771c256

Please sign in to comment.