#!/usr/bin/env bash # Run the p2p-intel Makepad app under a virtual X server and fail if it # cannot start. # # ## Why this exists, and what it is not # # `REVIEWS/PDF_PARITY_PHASE1_STATUS.md` records that Makepad has no headless # Linux backend: `platform/src/os/linux/windowing_backend.rs` knows only X11 # and Wayland, so on a machine with no display the app selects X11, finds # nothing, and dies. Six `ui.rs` tests across the repo are `#[ignore]`d for # that reason. # # That is still true. What this script does is sidestep it rather than fix # it: Xvfb *is* a real X11 server, it just draws into memory. So the app gets # the display it insists on, and everything from `script_mod!` parsing # through GL context creation to the first frame actually executes. # # The distinction matters and is not hand-waving: # # - This CAN catch a broken `script_mod!` block, a missing widget id, a # shader that will not compile, and a panic on startup. It found one the # day it was written: `Row = { ... }` is not valid in this fork's # script language, and no amount of `cargo build` would have said so, # because the block is parsed at runtime. # - This CANNOT drive widgets. `makepad_test`'s `Selector::id(..).click()` # needs the harness to own the event loop, which is the fork work that # is genuinely missing. The `#[ignore]`d interaction tests stay ignored. # # So this closes the "compiled but never executed" half of the gap and leaves # the "never interacted with" half open, honestly. # # Usage: # ./tools/test-p2p-app-smoke.sh # P2P_SMOKE_SECONDS=20 ./tools/test-p2p-app-smoke.sh set -Eeuo pipefail IFS=$'\n\t' ROOT="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" APP_DIR="$ROOT/crates/apps/p2p-intel" RUN_SECONDS="${P2P_SMOKE_SECONDS:-25}" for tool in xvfb-run cargo; do command -v "$tool" >/dev/null 2>&1 || { echo "missing: $tool" >&2 echo "install xvfb with: sudo apt-get install -y xvfb" >&2 exit 2 } done LOG="$(mktemp -t p2p-smoke.XXXXXXXX.log)" cleanup() { local status=$? rm -f "$LOG" exit "$status" } trap cleanup EXIT HUP INT TERM echo "building the app" # naga is memory-hungry; a parallel build gets OOM-killed on a small runner, # which presents as a bare SIGKILL with no error text. CARGO_BUILD_JOBS=1 cargo build --manifest-path "$APP_DIR/Cargo.toml" \ -p p2p-makepad --bin p2p-intel-app --features ui BIN="$(CARGO_BUILD_JOBS=1 cargo metadata --manifest-path "$APP_DIR/Cargo.toml" \ --format-version 1 --no-deps 2>/dev/null \ | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p')/debug/p2p-intel-app" [ -x "$BIN" ] || BIN="$APP_DIR/target/debug/p2p-intel-app" [ -x "$BIN" ] || { echo "could not locate the built binary" >&2; exit 1; } echo "running it for ${RUN_SECONDS}s under Xvfb" set +e timeout "$RUN_SECONDS" xvfb-run -a --server-args="-screen 0 1024x768x24" \ "$BIN" >"$LOG" 2>&1 status=$? set -e # 124 is `timeout` killing a still-running process, which is success: the app # was alive when we stopped it. Anything else means it exited on its own. if [ "$status" -ne 124 ] && [ "$status" -ne 0 ]; then echo "FAIL: the app exited early with status $status" >&2 cat "$LOG" >&2 exit 1 fi fail=0 # A `script_mod!` error is logged, not returned: the app keeps running with a # broken widget tree. Without this check the smoke test would pass while the # UI was empty, which is the exact "declared versus delivered" failure # REVIEWS/adr/0017 exists to prevent. if grep -qE '^\[E\]' "$LOG"; then echo "FAIL: the app logged errors at startup" >&2 grep -E '^\[E\]' "$LOG" >&2 fail=1 fi if ! grep -q 'Selected: .* backend' "$LOG"; then echo "FAIL: no windowing backend was selected" >&2 fail=1 fi if [ "$fail" -eq 0 ]; then echo "ok: the app started, parsed its widget tree and ran for ${RUN_SECONDS}s" fi exit "$fail"