#!/usr/bin/env bash # Run the examples' tests, each as a person runs the example: through `wai create` and `wai dev`. # # bash wai/quickstart/test/run-examples.sh portable|browser|apple|android [...] # # portable no browser, no macOS: remote-desktop, package-and-deliver, verify-receipts, # encoder-ingest (the last two build Rust projects against this checkout) # browser in a headless browser: video-room, watch-together, messaging, remote-desktop, # package-and-deliver # apple apple-app (macOS, Xcode) # android android-app (a JDK 17) # # The binaries come from WAI_DIST, an unpacked quickstart archive (its bin/ goes first on PATH, # and `wai dev` finds the relay, the room service and the room client beside itself), or from # PATH as it is. For `browser`: BROWSER_BIN (the host's browser; otherwise the automation # package's own), and the automation package installed from package-lock.json outside the tree # (npm ci --ignore-scripts) unless PLAYWRIGHT_HOST names one. Each test's own output is printed; # the last line says which passed. set -uo pipefail HERE=$(cd "$(dirname "$0")" && pwd) EX=$(cd "$HERE/../../examples" && pwd) [ $# -ge 1 ] || { sed -n '2,20p' "$0"; exit 2; } SET=$1; shift if [ -n "${WAI_DIST:-}" ]; then export PATH="$WAI_DIST/bin:$PATH"; fi command -v wai > /dev/null || { echo "no wai on PATH (give WAI_DIST)"; exit 2; } case "$SET" in portable) tests=(remote-desktop/test/remote-desktop.test.sh package-and-deliver/test/package-and-deliver.test.sh verify-receipts/test/verify-receipts.test.sh encoder-ingest/test/encoder-ingest.test.sh) ;; browser) tests=(video-room/test/video-room.test.mjs watch-together/test/watch-together.test.mjs messaging/test/messaging.test.mjs remote-desktop/test/remote-desktop.test.mjs package-and-deliver/test/package-and-deliver.test.mjs) ;; apple) tests=(apple-app/test/apple-app.test.sh) ;; android) tests=(android-app/test/android-app.test.sh) ;; *) echo "portable, browser, apple or android"; exit 2 ;; esac if [ $# -gt 0 ]; then keep=() for t in "${tests[@]}"; do for n in "$@"; do [ "${t%%/*}" = "$n" ] && keep+=("$t"); done; done tests=("${keep[@]}") fi if [ "$SET" = browser ] && [ -z "${PLAYWRIGHT_HOST:-}" ]; then PW=$(mktemp -d) cp "$HERE/package.json" "$HERE/package-lock.json" "$PW/" (cd "$PW" && npm ci --ignore-scripts --no-audit --no-fund > /dev/null) || { echo "npm ci failed"; exit 2; } export PLAYWRIGHT_HOST="$PW/node_modules" fi passed=() failed=() for t in "${tests[@]}"; do echo "== $t" start=$(date +%s) case "$t" in *.mjs) node "$EX/$t" ;; *) bash "$EX/$t" ;; esac s=$? echo "== $t: exit $s in $(( $(date +%s) - start )) s" if [ $s = 0 ]; then passed+=("${t%%/*}"); else failed+=("${t%%/*}"); fi done echo "examples ($SET): ${#passed[@]} passed${passed[*]:+ (${passed[*]})}; ${#failed[@]} failed${failed[*]:+ (${failed[*]})}" [ ${#failed[@]} = 0 ]