#!/usr/bin/env bash
set -euo pipefail
# This is intentionally not an ordinary unit-suite wrapper. Acceptance must
# fail closed when nginx is unavailable: nginx_binary=true (or another stub)
# cannot provide HTTP evidence.
if [[ -z "${NGINX_BINARY:-}" ]]; then
NGINX_BINARY="$(command -v nginx || true)"
fi
if [[ -z "$NGINX_BINARY" || ! -x "$NGINX_BINARY" ]]; then
printf '%s\n' 'real nginx is required; set NGINX_BINARY to an executable nginx' >&2
exit 2
fi
if [[ "$(basename "$NGINX_BINARY")" == "true" || "$(basename "$NGINX_BINARY")" == "false" ]]; then
printf '%s\n' 'NGINX_BINARY must be real nginx, not a test stub' >&2
exit 2
fi
export NGINX_BINARY
cargo test --locked --lib nginx::tests::emitted_config_passes_nginx_test_and_serves_routes -- --ignored --exact
cargo test --locked --lib nginx::tests::nginx_serves_distinct_metadata_for_shared_body -- --ignored --exact