#!jinja2
[cylc]
    [[events]]
        abort on stalled = True
        abort on inactivity = True
        inactivity = P1M
[scheduling]
    [[dependencies]]
        graph="t1 => t2 => t3"
[runtime]
    [[t1]]
        script = """
cylc hold "${CYLC_SUITE_NAME}"
LOG="${CYLC_SUITE_LOG_DIR}/log"
while ! grep -qF 'INFO - Command succeeded: hold_suite()' "${LOG}"; do
    sleep 1  # make sure hold completes
done
cylc reset --state='succeeded' "${CYLC_SUITE_NAME}" 't2.1'
while ! grep -q \
    "INFO - Command succeeded: reset_task_states(\\[u't2.1'\\],.*state=succeeded" \
    "${LOG}"
do
    sleep 1  # make sure reset succeeded completes
done
cylc reset --state='waiting' "${CYLC_SUITE_NAME}" 't2.1'
while ! grep -q \
    "INFO - Command succeeded: reset_task_states(\\[u't2.1'\\],.*state=waiting" \
    "${LOG}"
do
    sleep 1  # make sure reset waiting completes
done
cylc release "${CYLC_SUITE_NAME}"
"""
        [[[job]]]
            execution time limit = PT50S
        [[[events]]]
            failed handler = cylc release '%(suite)s'

    [[t2]]
        script = sleep 10; touch "${CYLC_SUITE_RUN_DIR}/t2.done"
    [[t3]]
        # This will fail if t3.1 starts together with t2.1
        script = test -e "${CYLC_SUITE_RUN_DIR}/t2.done"
