set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
WARN_FLAGS="-D warnings"
if [[ " $* " =~ " --relaxed " ]]; then
WARN_FLAGS=""
fi
if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v weston &> /dev/null; then
export WAYLAND_DISPLAY=wayland-ci-0
export XDG_RUNTIME_DIR="/tmp/xdg-runtime-$(id -u)"
mkdir -p "$XDG_RUNTIME_DIR"
chmod 700 "$XDG_RUNTIME_DIR"
weston \
--backend=headless \
--socket="$WAYLAND_DISPLAY" \
--idle-time=0 \
--log=/tmp/weston.log \
--no-config >/tmp/weston.stdout 2>&1 &
WESTON_PID=$!
echo "Waiting for Wayland socket at $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"
for i in {1..10}; do
if test -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"; then
echo "Wayland socket found after $i attempts"
break
fi
sleep 1
done
if ! kill -0 $WESTON_PID 2>/dev/null; then
echo "Weston process died unexpectedly"
cat /tmp/weston.log || true
cat /tmp/weston.stdout || true
exit 1
fi
echo "XDG_RUNTIME_DIR contents:"
ls -la "$XDG_RUNTIME_DIR" || true
echo "Weston log:"
grep -E "ERROR|warn|headless|listening" -i /tmp/weston.log || true
RUSTFLAGS="$WARN_FLAGS" RUSTDOCFLAGS="$WARN_FLAGS" cargo test
kill $WESTON_PID || true
else
RUSTFLAGS="$WARN_FLAGS" RUSTDOCFLAGS="$WARN_FLAGS" cargo test
fi