Files
marqdo-view/scripts/test-browser.sh
T
Marqdo View a802f96b6e
ci/woodpecker/push/woodpecker Pipeline was successful
feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
Replace the retired rc.2 Analysis v2/Trace v2/Execution Events v1 stack with the
single current contract family:

- Analysis v3 (ADR-0069 public boundary): one check --emit artifact carries the
  exact source, Markdown AST, heading scopes (heading_span + complete span),
  anchors, state-bearing references, calls, resources and diagnostics; the old
  revision-3 shape is rejected with a rebuild hint.
- Observation v1: one run/call --output jsonl stream (+ atomic
  --observation-file snapshot) decoded by one decoder and projected into the
  reader/SSE/export layers; stale/malformed/truncated/incomplete never render
  as success.
- CLI Tool revision 1: requires {api_revision:1, analysis:3, observation:1},
  product range >=3.0.0-rc.3,<4.0.0, only MARQDO_BIN and
  MARQDO_API_REVISION are consumed.
- Remove compatibility branches, retired flags/env vars and duplicate decoders;
  re-record Analysis v3 and Observation v1 fixtures; rewrite contract,
  integration and security tests (173 passing locally).
- Add check-no-legacy/check-docs/check-observation gates, rc.4 pins in the
  CI pipelines, 0.3.0 Tool bundle and evidence manifest support.

See issues #4, #5 and #6; acceptance baseline is CLI source
452e9a32bd9e40dba427d4180691c58bab74449e, archive
9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8.
2026-11-25 21:58:15 +08:00

95 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Browser acceptance for the Live reader: real Chromium, real frozen core
# pinned to marqdo 3.0.0-rc.4 (Analysis revision 3, Observation revision 1).
#
# Usage:
# MARQDO_BIN=/abs/path/marqdo scripts/test-browser.sh
#
# Requires `cd tests/browser && npm install` once (Playwright + Chromium).
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
: "${MARQDO_BIN:?set MARQDO_BIN to the frozen marqdo binary}"
if [[ ! -x "$MARQDO_BIN" ]]; then
echo "error: MARQDO_BIN is not executable: $MARQDO_BIN" >&2
exit 1
fi
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-$repo_root/tests/.cache/pw-browsers}"
export MQ_SCREENSHOT_DIR="${MQ_SCREENSHOT_DIR:-$repo_root/tests/browser/artifacts}"
if [[ ! -d "$repo_root/tests/browser/node_modules/playwright" ]]; then
echo "error: Playwright is not installed; run: (cd tests/browser && npm install)" >&2
exit 1
fi
if [[ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ]]; then
echo "error: Chromium is not installed; run: (cd tests/browser && npx playwright install chromium)" >&2
exit 1
fi
if [[ "${VIEW_USE_INSTALLED_TOOL:-0}" == 1 ]]; then
view=("$MARQDO_BIN" view)
else
binary="$repo_root/target/release/marqdo-view"
[[ -x "$binary" ]] || cargo build --release --locked
view=("$binary")
fi
server_pid=""
cleanup() {
if [[ -n "$server_pid" ]]; then
kill -- "-$server_pid" 2>/dev/null || true
wait "$server_pid" 2>/dev/null || true
server_pid=""
fi
}
trap cleanup EXIT
run_suite() {
local project="$1"
local log
log="$(mktemp "$repo_root/tests/.cache/browser-server.XXXXXX.log")"
echo "==> browser suite: $project"
setsid "${view[@]}" "$project" --port 0 --no-open >"$log" 2>&1 &
server_pid=$!
local url=""
for _ in $(seq 1 100); do
url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$log" | head -1 || true)"
[[ -n "$url" ]] && break
if ! kill -0 "$server_pid" 2>/dev/null; then
echo "error: server exited during startup:" >&2
cat "$log" >&2
exit 1
fi
sleep 0.1
done
if [[ -z "$url" ]]; then
echo "error: server did not print a URL" >&2
cat "$log" >&2
exit 1
fi
MQ_URL="$url" MQ_PROJECT="$project" node tests/browser/reader.browser.cjs
cleanup
if curl -fsS --max-time 2 "$url" >/dev/null 2>&1; then
echo "error: test server remained active after cleanup" >&2
exit 1
fi
rm -f "$log"
}
mkdir -p "$repo_root/tests/.cache" "$MQ_SCREENSHOT_DIR"
run_suite examples/welcome
run_suite examples/control-flow
run_suite examples/function-params.mq.md
run_suite tests/fixtures/security-project
core_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
if [[ "$core_before" != "$core_after" ]]; then
echo "error: frozen core binary changed during browser tests" >&2
exit 1
fi
echo "browser: PASS (core sha256 $core_before unchanged; screenshots: $MQ_SCREENSHOT_DIR)"