[meta]
    title = "Test reloading of a task removed then added by a reload."
# Don't run this suite in-place: it modifies itself.

[cylc]
    UTC mode = True

[scheduling]
    [[graph]]
        R1 = reloader => remove_add_alter_me

[runtime]
   [[remove_add_alter_me]]
      script = false
   [[reloader]]
      script = """
do_reload() {
    cylc reload "${CYLC_SUITE_NAME}"
    while test "$(grep -cF 'Reload completed' "${CYLC_SUITE_LOG_DIR}/log")" -ne "$1"
    do
        sleep 1
    done
}
sed -i "s/\(R1 = reloader\).*/\1/" "${CYLC_SUITE_DEF_PATH}/suite.rc"
do_reload 1
sed -i "s/\(R1 = reloader\)/\1 => remove_add_alter_me/" \
    "${CYLC_SUITE_DEF_PATH}/suite.rc"
do_reload 2
cylc insert "${CYLC_SUITE_NAME}" 'remove_add_alter_me.1'
while ! grep -qF 'remove_add_alter_me' < <(cylc dump -t "${CYLC_SUITE_NAME}")
do
    sleep 1
done
cat >>"${CYLC_SUITE_DEF_PATH}/suite.rc" <<'__RUNTIME__'
[[remove_add_alter_me]]
    script = true
__RUNTIME__
do_reload 3
"""
