#!/usr/bin/env bash

cat <<EOF >mise.toml
[tasks.a]
run = 'echo running a'
[tasks.b]
depends = 'a'
run = 'echo running b'
[tasks.c]
depends = ['b']
run = 'echo running c'
[tasks.all]
depends = ['a', 'b', 'c']
depends_post = 'z'
run = 'echo running all'
[tasks.d]
run = 'echo running d'
[tasks.z]
run = 'echo running z'
EOF

MISE_TASK_OUTPUT=silent assert_empty "mise run all" ""
MISE_TASK_OUTPUT=quiet assert "mise run all" "running a
running b
running c
running all
running z"
MISE_TASK_OUTPUT=interleave assert "mise run all" "running a
running b
running c
running all
running z"
MISE_TASK_OUTPUT=prefix assert "mise run all" "[a] running a
[b] running b
[c] running c
[all] running all
[z] running z"
# defaults to interleave if linear depedency graph
assert "mise run all" "running a
running b
running c
running all
running z"
# now the graph isn't linear so it uses prefix
assert_contains "mise run a ::: d" "[a] running a"
assert_contains "mise run a ::: d" "[d] running d"
assert "mise task deps" "a
all
├── c
│   └── b
│       └── a
├── b
│   └── a
└── a
b
└── a
c
└── b
    └── a
d
z
├── all
│   ├── c
│   │   └── b
│   │       └── a
│   ├── b
│   │   └── a
│   └── a
├── a
├── b
│   └── a
├── c
│   └── b
│       └── a
└── d"
