| 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 the --format option. |
| 19 |
|
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
set_test_number 6 |
| 22 |
|
| 23 |
init_workflow "${TEST_NAME_BASE}" << '__EOF__' |
| 24 |
[scheduler] |
| 25 |
[[events]] |
| 26 |
stall timeout = PT0S |
| 27 |
abort on stall timeout = True |
| 28 |
[scheduling] |
| 29 |
[[graph]] |
| 30 |
R1 = foo |
| 31 |
[runtime] |
| 32 |
[[foo]] |
| 33 |
pre-script = """ |
| 34 |
cylc broadcast "$CYLC_WORKFLOW_ID" \ |
| 35 |
-p "$CYLC_TASK_CYCLE_POINT" -n "$CYLC_TASK_NAME" \ |
| 36 |
--set '[environment]horse=dorothy' \ |
| 37 |
--set 'post-script=echo "$horse"' |
| 38 |
""" |
| 39 |
script = """ |
| 40 |
cylc broadcast "$CYLC_WORKFLOW_ID" --display --format json > out.json |
| 41 |
cylc broadcast "$CYLC_WORKFLOW_ID" --display --format raw > raw1.stdout |
| 42 |
# Test deprecated option: |
| 43 |
cylc broadcast "$CYLC_WORKFLOW_ID" --display --raw 1> raw2.stdout 2> raw2.stderr |
| 44 |
""" |
| 45 |
__EOF__ |
| 46 |
|
| 47 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 48 |
workflow_run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" --no-detach |
| 49 |
|
| 50 |
FOO_WORK_DIR="${WORKFLOW_RUN_DIR}/work/1/foo" |
| 51 |
|
| 52 |
TEST_NAME="${TEST_NAME_BASE}-cmp-json" |
| 53 |
cmp_json "$TEST_NAME" "${FOO_WORK_DIR}/out.json" << '__EOF__' |
| 54 |
{ |
| 55 |
"1": { |
| 56 |
"foo": { |
| 57 |
"environment": { |
| 58 |
"horse": "dorothy" |
| 59 |
}, |
| 60 |
"post-script": "echo \"$horse\"" |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
__EOF__ |
| 65 |
|
| 66 |
cmp_ok "${FOO_WORK_DIR}/raw1.stdout" << '__EOF__' |
| 67 |
{'1': {'foo': {'environment': {'horse': 'dorothy'}, 'post-script': 'echo "$horse"'}}} |
| 68 |
__EOF__ |
| 69 |
|
| 70 |
cmp_ok "${FOO_WORK_DIR}/raw2.stdout" "${FOO_WORK_DIR}/raw1.stdout" |
| 71 |
|
| 72 |
cmp_ok "${FOO_WORK_DIR}/raw2.stderr" << __EOF__ |
| 73 |
DEPRECATED: the --raw option will be removed at Cylc 8.7; use --format=raw instead. |
| 74 |
__EOF__ |
| 75 |
|
| 76 |
purge |