#!/usr/bin/env bash

# When source_freshness_hash_contents=true and a task has multiple outputs,
# deleting any one of them must trigger a rebuild even when the source hash
# still matches. Previously, get_last_modified(...).is_some() returned true
# as long as at least one output existed, so a partial output set was
# incorrectly treated as fresh.

cat <<EOF >mise.toml
[settings.task]
source_freshness_hash_contents = true

[tasks.build]
run = 'touch out_a.txt out_b.txt && echo built'
sources = ['src.txt']
outputs = ['out_a.txt', 'out_b.txt']
EOF

echo "hello" >src.txt

# First run: no stored hash, no outputs → stale → runs
assert "mise run -q build" "built"

# Both outputs present, source unchanged → fresh
assert_empty "mise run -q build"

# Delete one output — source hash still matches, but output set is incomplete
rm out_b.txt
assert "mise run -q build" "built"

# Both outputs restored → fresh again
assert_empty "mise run -q build"
