#!/usr/bin/env bash
# misc_br_explicit_raw — `bug-report --yes --model X.dzn
# --no-anonymize`: the explicit opt-out from anonymize must give
# `model/model.flat.dzn` (NO `.anon` suffix).
set -euo pipefail

cat > "$NUCTEST_TMPDIR/Foo.dzn" <<'EOF'
interface IFoo { in void e(); behavior { on e: {} } }
component Foo { provides IFoo p; behavior { on p.e(): {} } }
EOF

"$NUCLEOS" bug-report --yes --no-last-panic --no-last-run \
    --model "$NUCTEST_TMPDIR/Foo.dzn" --no-anonymize \
    -o "$NUCTEST_TMPDIR/bug.tar.gz" \
    < /dev/null > "$NUCTEST_TMPDIR/out.txt" 2> "$NUCTEST_TMPDIR/err.txt"

listing=$(tar tzf "$NUCTEST_TMPDIR/bug.tar.gz")
if ! echo "$listing" | grep -q '/model/model\.flat\.dzn$'; then
    echo "FAIL: archive missing model.flat.dzn" >&2
    echo "$listing" >&2
    exit 1
fi
if echo "$listing" | grep -q '/model/model\.flat\.anon\.dzn$'; then
    echo "FAIL: archive has .anon.dzn even with --no-anonymize" >&2
    echo "$listing" >&2
    exit 1
fi
