[meta]
    title=broadcast expire
    description=Test broadcast expire option

[scheduler]
    UTC mode = True

[scheduling]
    initial cycle point = 2020
    final cycle point = 2025
    [[graph]]
        P5Y="""
            broadcast => t1 => broadcast-expire => t2
            t2[-P5Y] => broadcast-expire
        """

[runtime]
    [[broadcast]]
        script = """
            cylc broadcast \
                -s '[environment]FABRIC=Wool' \
                -s "[environment]ORGANISM=sheep" \
                -p "${CYLC_TASK_CYCLE_POINT}" \
                -n 'F1' \
                "${CYLC_WORKFLOW_ID}" \
                | tee 'broadcast.out'
        """
        post-script = """
            diff -u - 'broadcast.out' <<__OUT__
            Broadcast set:
            + [${CYLC_TASK_CYCLE_POINT}/F1] [environment]FABRIC=Wool
            + [${CYLC_TASK_CYCLE_POINT}/F1] [environment]ORGANISM=sheep
            __OUT__
        """
    [[broadcast-expire]]
        script = """
            NEXT_CYCLE_POINT=$(cylc cycletime --offset=P5Y)
            cylc broadcast --expire="${NEXT_CYCLE_POINT}" "${CYLC_WORKFLOW_ID}" \
                | tee 'broadcast.out'
        """
        post-script = """
            diff -u - 'broadcast.out' <<__OUT__
            Broadcast cancelled:
            - [${CYLC_TASK_CYCLE_POINT}/F1] [environment]FABRIC=Wool
            - [${CYLC_TASK_CYCLE_POINT}/F1] [environment]ORGANISM=sheep
            __OUT__
        """
    [[F1]]
        script = """
            echo "${FABRIC} is from ${ORGANISM}." | tee 'echo.out'
        """
        [[[environment]]]
            FABRIC=Silk
            ORGANISM=silk worm
    [[t1]]
        inherit=F1
        post-script="""
            diff -u - 'echo.out' <<<'Wool is from sheep.'
        """
    [[t2]]
        inherit=F1
        post-script="""
            diff -u - 'echo.out' <<<'Silk is from silk worm.'
        """
