#!/bin/sh
# (C) 2013 Canonical Ltd.
# (C) 2019 Simon McVittie
# Authors: Iain Lane, Simon McVittie
# SPDX-License-Identifier: LGPL-2.0-or-later

set -eu

export G_MESSAGES_DEBUG=all
export NO_AT_BRIDGE=1
export XDG_RUNTIME_DIR="$AUTOPKGTEST_TMP"

printf "Running as: "; id -a
printf "passwd entry: "; getent passwd "$(id -u)" || echo "(exit status $?)"
printf "group entry: "; getent group "$(id -g)" || echo "(exit status $?)"
echo "Environment:"
env | LC_ALL=C sort -u

if ! gnome-desktop-testing-runner -l gnome-desktop | grep '^gnome-desktop/'; then
    echo "No tests found. Does debian/tests/installed-tests need updating?" >&2
    exit 1
fi

dbus-run-session -- \
xvfb-run -a \
debian/tests/run-with-locales \
    --generate en_US.UTF-8 \
    --generate he_IL.UTF-8 \
    --generate ja_JP.UTF-8 \
    -- \
gnome-desktop-testing-runner \
	--tap \
	--log-directory "$AUTOPKGTEST_ARTIFACTS" \
	gnome-desktop
