#!/usr/bin/env bash
# misc_filenotfound — `nucleos verify <missing>` must byte-match `dzn verify`.
#
# When the top-level model file does not exist, dzn reports just the OS
# message followed by the path and exits 1:
#
#   No such file or directory: nope.dzn
#
# nucleos used to print its own `Cannot resolve path nope.dzn: No such file
# or directory (os error 2)`. This pins the dzn-identical wording.
set -euo pipefail

# Isolate in a scratch dir so the path in the message is a bare basename.
work="$NUCTEST_TMPDIR/fnf"
rm -rf "$work"; mkdir -p "$work"
cd "$work"

out=$("$NUCLEOS" verify nope.dzn 2>&1) && rc=0 || rc=$?

expected="No such file or directory: nope.dzn"

if [[ "$out" != "$expected" ]]; then
  echo "FAIL: file-not-found output != dzn reference"
  echo "--- expected (dzn) ---"; printf '%s\n' "$expected"
  echo "--- got (nucleos) ---";  printf '%s\n' "$out"
  exit 1
fi

# dzn exits 1 when the file is missing.
if [[ "$rc" -ne 1 ]]; then
  echo "FAIL: expected exit 1 (missing file), got $rc"
  exit 1
fi

echo "ok: missing model file reported byte-identical to dzn (exit 1)"
