-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/run-test.sh: Add new tool to simplify running tests
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
Showing
2 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# | ||
# - Runs pytest with the required environment to run tests on an x-d-p build | ||
# - By default, the tests run on the first x-d-p build directory that is found | ||
# inside the source tree | ||
# - The BUILDDIR environment variable can be set to a specific x-d-p build | ||
# directory | ||
# - 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 | ||
|
||
function fail() | ||
{ | ||
sed -n '/^#$/,/^$/p' ${BASH_SOURCE[0]} | ||
echo $1 | ||
exit 1 | ||
} | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
BUILDDIR=${BUILDDIR:-$(find "${SCRIPT_DIR}/.." -maxdepth 2 -name 'build.ninja' -printf "%h\n" -quit)} | ||
|
||
[ ! -f "${BUILDDIR}/build.ninja" ] && fail "Path '${BUILDDIR}' does not appear to be a build dir" | ||
|
||
echo "Running tests on build dir: $(readlink -f "${BUILDDIR}")" | ||
echo "" | ||
|
||
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 $@ |