#!/bin/sh
set -uxe

meson build
# XDG_RUNTIME_DIR will be used for an AF unix socket, so override it to avoid
# permission errors and leaving files around
SOCKET_DIR=$(mktemp --directory)
ret=0
MESON_TESTTHREADS=1 XDG_RUNTIME_DIR=${SOCKET_DIR} meson test -C build --verbose --suite fast-tests -t 3 || ret=$?
if [ $ret -eq 125 ]; then
    echo "Warning: failed in build stage before actual tests skipping"
    exit 77
fi
rm -rf "${SOCKET_DIR}"
exit $ret
