# Test that `cylc set` has the same effect as natural output
# completion: i.e. that downstream children are spawned as normal.

[scheduler]
    [[events]]
        abort on stall timeout = True
        stall timeout = PT0S
        inactivity timeout = PT30S
        abort on inactivity timeout = True

[scheduling]
    [[graph]]
        R1 = """
            foo & bar & setter

            # Task scripting below ensures that foo is still in the pool, but
            # bar is gone, when its outputs get set - just to make it clear
            # the target task doesn't have to exist.

            foo:out1? => qux
            foo:out2? => quw

            bar:out1? => fux
            bar:out2? => fuw
        """

[runtime]
    [[foo, bar]]
        # (Neglecting to complete my outputs naturally).
        [[[outputs]]]
            out1 = "file-1 done"
            out2 = "file-2 done"
    [[foo]]
        # Hang about until setter is finished.
        script = """
            cylc__job__poll_grep_workflow_log -E "1/setter.* => succeeded"
        """
    [[bar]]
        script = true
    [[setter]]
        # (To the rescue).
        script = """
            # Set foo outputs while it still exists in the pool.
            cylc set --flow=2 --output=out1 --output=out2 "${CYLC_WORKFLOW_ID}//1/foo"

            # Set bar outputs after it is gone from the pool.
            cylc__job__poll_grep_workflow_log -E "1/bar.* completed"
            cylc set --flow=2 --output=out1 --output=out2 "${CYLC_WORKFLOW_ID}//1/bar"
        """
    [[qux, quw, fux, fuw]]
        script = true
