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

[scheduler]
    UTC mode = True
    allow implicit tasks = True

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

[runtime]
   [[remove_add_alter_me]]
      script = false
   [[reloader]]
      script = """
do_reload() {
    cylc reload "${CYLC_WORKFLOW_ID}"
    while test "$(grep -cF 'Reload completed' "${CYLC_WORKFLOW_LOG_DIR}/log")" -ne "$1"
    do
        sleep 1
    done
}
sed -i "s/\(R1 = reloader => inter\).*/\1/" "${CYLC_WORKFLOW_RUN_DIR}/flow.cylc"
do_reload 1
sed -i "s/\(R1 = reloader => inter\)/\1 => remove_add_alter_me/" \
    "${CYLC_WORKFLOW_RUN_DIR}/flow.cylc"
do_reload 2
cat >>"${CYLC_WORKFLOW_RUN_DIR}/flow.cylc" <<'__RUNTIME__'
[[remove_add_alter_me]]
    script = true
__RUNTIME__
do_reload 3
"""
