#!/bin/bash # Test runner for smesh. # # Usage: # ./test/run.sh # headless, all tests # ./test/run.sh --headed # visible browser # ./test/run.sh -k smoke # only smoke tests # ./test/run.sh -k signer -v # verbose signer tests # ./test/run.sh --build # rebuild before testing # # Prerequisites: # pacman -S geckodriver python-pytest # pip install selenium (or: pacman -S python-selenium) set -euo pipefail cd "$(dirname "$0")/.." ROOT="$PWD" BUILD=false PYTEST_ARGS=() for arg in "$@"; do case "$arg" in --build) BUILD=true ;; *) PYTEST_ARGS+=("$arg") ;; esac done # ── Build if requested ── if $BUILD; then echo "=== Building relay ===" MOXIEROOT=../moxie ../moxie/moxie build -o smesh . echo "=== Building frontend ===" make build-app build-sw build-signer-bg fi # ── Verify binaries exist ── if [ ! -f "$ROOT/smesh" ]; then echo "error: relay binary not found. Run with --build or: make build-relay" >&2 exit 1 fi if [ ! -f "$ROOT/web/static/\$entry.mjs" ]; then echo "error: app not compiled. Run with --build or: make build-app" >&2 exit 1 fi # ── Clean test data ── rm -rf /tmp/smesh-test-data # ── Run tests ── exec python3 -m pytest test/ \ --tb=short \ -x \ "${PYTEST_ARGS[@]}"