AnyBot/deploy/linux/dev/test.sh

30 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Build and test the Linux version from a Mac (or anywhere with Docker), on a virtual screen.
# docker build -t anybot-linux-dev deploy/linux/dev (once)
# deploy/linux/dev/test.sh (from app/)
# Runs: every unit test; the live X11 test (screenshot, clicks, keys, recording a demo); the live Wayland test (headless sway: screenshot,
# clicks, Chinese typing, keys, scroll); and screenshots of the window into ./linux-shots.
set -e
cd "$(dirname "$0")/../../.."
mkdir -p linux-shots
docker run --rm -v "$PWD":/src -v anybot-linux-target:/target -v anybot-linux-cargo:/usr/local/cargo/registry \
-v "$PWD/linux-shots":/out -e CARGO_TARGET_DIR=/target -w /src anybot-linux-dev sh -c '
set -e
cargo build --release 2>&1 | grep -E "^(error|warning)" -A7 || true
Xvfb :99 -screen 0 1400x900x24 >/dev/null 2>&1 &
export DISPLAY=:99 LANG=zh_TW.UTF-8
sleep 1
# (A failing test stops here: piped straight into grep, the result was the one grep gave.)
run_tests() {
cargo test --release "$@" >/tmp/anybot-test.log 2>&1 && rc=0 || rc=$?
grep -E "test result|FAILED|panicked" /tmp/anybot-test.log || true
return $rc
}
run_tests
run_tests x11_live -- --ignored
useradd -m t 2>/dev/null; chmod 777 /out
runuser -u t -- env CARGO_TARGET_DIR=/target HOME=/home/t sh deploy/linux/dev/wayland_live.sh 2>&1 | sed -n "/--- wev heard/,\$p"
for v in chat computers general; do
ANYBOT_DATA_DIR=/tmp/anybot-data ANYBOT_SHOT_VIEW=$v ANYBOT_SHOT_DARK=1 timeout 90 /target/release/anybot --screenshot /out/$v.png >/dev/null 2>&1 && echo "shot $v"
done'