Skip to content

Commit

Permalink
tests/run-test.sh: Add new tool to simplify running tests
Browse files Browse the repository at this point in the history
Running the tests outside of meson gives more control but also requires
setting up a bunch of environment variables. The new script sets
everything up automatically if the standard build directory is used.
  • Loading branch information
swick committed Jan 16, 2025
1 parent 7928c83 commit 133492c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# - Sets up the required environment to run tests based on the build dir.
# - If another build directory is used, it can be set in the BUILDDIR env
# variable.
# - All arguments are passed along to pytest.
# - Check tests/README.md for useful environment variables
#
# Examples:
#
# ./run-test.sh ./test_camera.py -k test_version -v -s
#
# BUILDDIR=../_build ./run-test.sh ./test_usb.py
#

set -euo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

BUILDDIR="${BUILDDIR:-$SCRIPT_DIR/../build}"

[ ! -d $BUILDDIR ] && echo "Env BUILDDIR must be set to the build dir" && exit 1

export XDP_VALIDATE_SOUND=$BUILDDIR/src/xdg-desktop-portal-validate-sound
export XDP_VALIDATE_ICON=$BUILDDIR/src/xdg-desktop-portal-validate-icon
export XDG_DESKTOP_PORTAL_PATH=$BUILDDIR/src/xdg-desktop-portal
export XDG_DOCUMENT_PORTAL_PATH=$BUILDDIR/document-portal/xdg-document-portal
export XDG_PERMISSION_STORE_PATH=$BUILDDIR/document-portal/xdg-permission-store
exec pytest-3 $@

0 comments on commit 133492c

Please sign in to comment.