run.sh raw

   1  #!/bin/bash
   2  # Test runner for smesh.
   3  #
   4  # Usage:
   5  #   ./test/run.sh                 # headless, all tests
   6  #   ./test/run.sh --headed        # visible browser
   7  #   ./test/run.sh -k smoke        # only smoke tests
   8  #   ./test/run.sh -k signer -v    # verbose signer tests
   9  #   ./test/run.sh --build         # rebuild before testing
  10  #
  11  # Prerequisites:
  12  #   pacman -S geckodriver python-pytest
  13  #   pip install selenium  (or: pacman -S python-selenium)
  14  
  15  set -euo pipefail
  16  
  17  cd "$(dirname "$0")/.."
  18  ROOT="$PWD"
  19  
  20  BUILD=false
  21  PYTEST_ARGS=()
  22  
  23  for arg in "$@"; do
  24      case "$arg" in
  25          --build) BUILD=true ;;
  26          *)       PYTEST_ARGS+=("$arg") ;;
  27      esac
  28  done
  29  
  30  # ── Build if requested ──
  31  if $BUILD; then
  32      echo "=== Building relay ==="
  33      MOXIEROOT=../moxie ../moxie/moxie build -o smesh .
  34  
  35      echo "=== Building frontend ==="
  36      make build-app build-sw build-signer-bg
  37  fi
  38  
  39  # ── Verify binaries exist ──
  40  if [ ! -f "$ROOT/smesh" ]; then
  41      echo "error: relay binary not found. Run with --build or: make build-relay" >&2
  42      exit 1
  43  fi
  44  
  45  if [ ! -f "$ROOT/web/static/\$entry.mjs" ]; then
  46      echo "error: app not compiled. Run with --build or: make build-app" >&2
  47      exit 1
  48  fi
  49  
  50  # ── Clean test data ──
  51  rm -rf /tmp/smesh-test-data
  52  
  53  # ── Run tests ──
  54  exec python3 -m pytest test/ \
  55      --tb=short \
  56      -x \
  57      "${PYTEST_ARGS[@]}"
  58