| 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 |
|
| 19 |
# test the output of `cylc play` with different `--format` options |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
|
| 23 |
set_test_number 8 |
| 24 |
|
| 25 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 26 |
[scheduler] |
| 27 |
allow implicit tasks = True |
| 28 |
[scheduling] |
| 29 |
[[dependencies]] |
| 30 |
R1 = foo |
| 31 |
__FLOW_CONFIG__ |
| 32 |
|
| 33 |
TEST_NAME="${TEST_NAME_BASE}-validate" |
| 34 |
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}" |
| 35 |
|
| 36 |
# format=plain |
| 37 |
TEST_NAME="${TEST_NAME_BASE}-run-format-plain" |
| 38 |
workflow_run_ok "${TEST_NAME}" cylc play --format plain "${WORKFLOW_NAME}" |
| 39 |
grep_ok "Copyright" "${TEST_NAME}.stdout" |
| 40 |
grep_ok "${WORKFLOW_NAME}:" "${TEST_NAME}.stdout" |
| 41 |
|
| 42 |
poll_workflow_running |
| 43 |
poll_workflow_stopped |
| 44 |
delete_db |
| 45 |
|
| 46 |
# format=json |
| 47 |
TEST_NAME="${TEST_NAME_BASE}-run-format-json" |
| 48 |
workflow_run_ok "${TEST_NAME}" cylc play --format json "${WORKFLOW_NAME}" |
| 49 |
run_ok "${TEST_NAME}-fields" python3 -c ' |
| 50 |
import json |
| 51 |
import sys |
| 52 |
data = json.load(open(sys.argv[1], "r")) |
| 53 |
print(list(sorted(data)), file=sys.stderr) |
| 54 |
assert list(sorted(data)) == [ |
| 55 |
"host", "pid", "pub_url", "url", "workflow"] |
| 56 |
' "${TEST_NAME}.stdout" |
| 57 |
|
| 58 |
poll_workflow_running |
| 59 |
poll_workflow_stopped |
| 60 |
delete_db |
| 61 |
|
| 62 |
# quiet |
| 63 |
TEST_NAME="${TEST_NAME_BASE}-run-quiet" |
| 64 |
workflow_run_ok "${TEST_NAME}" cylc play --quiet "${WORKFLOW_NAME}" |
| 65 |
grep_ok "${WORKFLOW_NAME}:" "${TEST_NAME}.stdout" |
| 66 |
|
| 67 |
poll_workflow_running |
| 68 |
poll_workflow_stopped |
| 69 |
purge |