| 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 that known task outputs can be used as events. |
| 19 |
|
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
|
| 22 |
set_test_number 4 |
| 23 |
|
| 24 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 25 |
[scheduling] |
| 26 |
[[graph]] |
| 27 |
R1 = t1 |
| 28 |
[runtime] |
| 29 |
[[t1]] |
| 30 |
script=""" |
| 31 |
cylc message -- ${CYLC_WORKFLOW_ID} ${CYLC_TASK_JOB} \ |
| 32 |
'rose' 'lily' 'iris' 'WARNING:poison ivy' |
| 33 |
""" |
| 34 |
[[[outputs]]] |
| 35 |
rose = rose |
| 36 |
lily = lily |
| 37 |
iris = iris |
| 38 |
[[[events]]] |
| 39 |
handler events = rose, lily, iris, warning, arsenic |
| 40 |
# (arsenic is an invalid event) |
| 41 |
handlers = echo %(message)s |
| 42 |
__FLOW_CONFIG__ |
| 43 |
|
| 44 |
TEST_NAME="${TEST_NAME_BASE}-validate" |
| 45 |
run_ok "$TEST_NAME" cylc validate "${WORKFLOW_NAME}" |
| 46 |
|
| 47 |
dump_std "${TEST_NAME}" |
| 48 |
grep_ok 'WARNING - Invalid event name.*arsenic' "${TEST_NAME}.stderr" |
| 49 |
|
| 50 |
workflow_run_ok "${TEST_NAME_BASE}-run" \ |
| 51 |
cylc play --debug --no-detach "${WORKFLOW_NAME}" |
| 52 |
cylc cat-log "${WORKFLOW_NAME}" \ |
| 53 |
| sed -n -e 's/^.*\(\[(('"'"'event-handler-00'"'"'.*$\)/\1/p' | sort >'log' |
| 54 |
|
| 55 |
cmp_ok log <<__END__ |
| 56 |
[(('event-handler-00', 'iris'), 1) cmd] echo iris |
| 57 |
[(('event-handler-00', 'iris'), 1) out] iris |
| 58 |
[(('event-handler-00', 'iris'), 1) ret_code] 0 |
| 59 |
[(('event-handler-00', 'lily'), 1) cmd] echo lily |
| 60 |
[(('event-handler-00', 'lily'), 1) out] lily |
| 61 |
[(('event-handler-00', 'lily'), 1) ret_code] 0 |
| 62 |
[(('event-handler-00', 'rose'), 1) cmd] echo rose |
| 63 |
[(('event-handler-00', 'rose'), 1) out] rose |
| 64 |
[(('event-handler-00', 'rose'), 1) ret_code] 0 |
| 65 |
[(('event-handler-00', 'warning-1'), 1) cmd] echo 'poison ivy' |
| 66 |
[(('event-handler-00', 'warning-1'), 1) out] poison ivy |
| 67 |
[(('event-handler-00', 'warning-1'), 1) ret_code] 0 |
| 68 |
__END__ |
| 69 |
|
| 70 |
purge |
| 71 |
exit |