| 1 |
#!/usr/bin/env bash |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
#------------------------------------------------------------------------------- |
| 18 |
# Test environment filtering |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
#------------------------------------------------------------------------------- |
| 21 |
set_test_number 13 |
| 22 |
#------------------------------------------------------------------------------- |
| 23 |
# a test workflow that uses environment filtering: |
| 24 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 25 |
[scheduling] |
| 26 |
[[graph]] |
| 27 |
R1 = "foo & bar & baz & qux" |
| 28 |
[runtime] |
| 29 |
[[root]] |
| 30 |
[[[environment]]] |
| 31 |
FOO = foo |
| 32 |
BAR = bar |
| 33 |
BAZ = baz |
| 34 |
[[foo]] |
| 35 |
[[[environment filter]]] |
| 36 |
include = FOO, BAR |
| 37 |
[[[environment]]] |
| 38 |
QUX = qux |
| 39 |
[[bar]] |
| 40 |
[[[environment filter]]] |
| 41 |
include = FOO, BAR |
| 42 |
exclude = FOO |
| 43 |
[[baz]] |
| 44 |
[[[environment filter]]] |
| 45 |
exclude = FOO, BAR |
| 46 |
[[[environment]]] |
| 47 |
QUX = qux |
| 48 |
[[qux]] |
| 49 |
[[[environment]]] |
| 50 |
QUX = qux |
| 51 |
__FLOW_CONFIG__ |
| 52 |
#------------------------------------------------------------------------------- |
| 53 |
# check validation |
| 54 |
TEST_NAME="${TEST_NAME_BASE}-validate" |
| 55 |
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}" |
| 56 |
#------------------------------------------------------------------------------- |
| 57 |
# check that config retrieves only the filtered environment |
| 58 |
TEST_NAME=${TEST_NAME_BASE}-config |
| 59 |
|
| 60 |
run_ok "${TEST_NAME}" cylc config --item='[runtime][foo]environment' "${WORKFLOW_NAME}" |
| 61 |
cmp_ok "${TEST_NAME}.stdout" - <<__OUT__ |
| 62 |
FOO = foo |
| 63 |
BAR = bar |
| 64 |
__OUT__ |
| 65 |
cmp_ok "${TEST_NAME}.stderr" - </dev/null |
| 66 |
|
| 67 |
run_ok "${TEST_NAME}" cylc config --item='[runtime][bar]environment' "${WORKFLOW_NAME}" |
| 68 |
cmp_ok "${TEST_NAME}.stdout" - <<__OUT__ |
| 69 |
BAR = bar |
| 70 |
__OUT__ |
| 71 |
cmp_ok "${TEST_NAME}.stderr" - </dev/null |
| 72 |
|
| 73 |
run_ok "${TEST_NAME}" cylc config --item='[runtime][baz]environment' "${WORKFLOW_NAME}" |
| 74 |
cmp_ok "${TEST_NAME}.stdout" - <<__OUT__ |
| 75 |
BAZ = baz |
| 76 |
QUX = qux |
| 77 |
__OUT__ |
| 78 |
cmp_ok "${TEST_NAME}.stderr" - </dev/null |
| 79 |
|
| 80 |
run_ok "${TEST_NAME}" cylc config --item='[runtime][qux]environment' "${WORKFLOW_NAME}" |
| 81 |
cmp_ok "${TEST_NAME}.stdout" - <<__OUT__ |
| 82 |
FOO = foo |
| 83 |
BAR = bar |
| 84 |
BAZ = baz |
| 85 |
QUX = qux |
| 86 |
__OUT__ |
| 87 |
cmp_ok "${TEST_NAME}.stderr" - </dev/null |
| 88 |
|
| 89 |
#------------------------------------------------------------------------------- |
| 90 |
purge |
| 91 |
exit |