# Workflow testing --keep-going with mixed success/failure branches
# Tests: independent branches continuing after failures

# Branch A: will fail
# Branch B: will succeed
# Branch C: will fail
# Final: depends on all (won't run due to failures)

rule all:
    input:
        "output/final.txt"

# Successful branch B
rule branch_b_step1:
    output: "output/b_step1.txt"
    shell: "echo 'B step 1' > {output}"

rule branch_b_step2:
    input: "output/b_step1.txt"
    output: "output/b_complete.txt"
    shell: "cat {input} && echo 'B complete' > {output}"

# Failing branch A
rule branch_a_step1:
    output: "output/a_step1.txt"
    shell: "echo 'A step 1' > {output}"

rule branch_a_fails:
    input: "output/a_step1.txt"
    output: "output/a_complete.txt"
    shell:
        """
        sleep 0.3
        echo "Branch A failing"
        exit 1
        """

# Failing branch C (independent of A)
rule branch_c_fails:
    output: "output/c_complete.txt"
    shell:
        """
        sleep 0.3
        echo "Branch C failing"
        exit 1
        """

# Final aggregation (won't run)
rule aggregate:
    input:
        "output/a_complete.txt",
        "output/b_complete.txt",
        "output/c_complete.txt"
    output: "output/final.txt"
    shell: "cat {input} > {output}"
