# 3/foo triggers a new flow at 1/foo and waits for it to catch up and merge.
# bar checks for the expected flow names at each cycle point.
[scheduling]
    cycling mode = integer
    initial cycle point = 1
    final cycle point = 3
    [[graph]]
        P1 = "foo[-P1] => foo => bar"
[runtime]
    [[foo]]
        script = """
            if (( CYLC_TASK_CYCLE_POINT == 3 )); then
                cylc trigger --flow=new --meta=other "${CYLC_WORKFLOW_ID}//1/foo"
                cylc__job__poll_grep_workflow_log 'merged in'
            fi
        """
    [[bar]]
        script = """
            if [[ $CYLC_TASK_JOB == *01 ]]; then
                # job(01)
                if (( CYLC_TASK_CYCLE_POINT == 3 )); then
                    test $CYLC_TASK_FLOW_NUMBERS == "1,2"
                else
                    test $CYLC_TASK_FLOW_NUMBERS == "1"
                fi
            else
                # job(02)
                test $CYLC_TASK_FLOW_NUMBERS == "2"
            fi
        """
