-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathpytest
executable file
·33 lines (26 loc) · 988 Bytes
/
pytest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
################################################################################
# Runs pytest on the repository.
#
# Usage:
# check/pytest [--flags for pytest] [file-paths-relative-to-repo-root]
#
# You may specify pytest flags and specific files to test. The file paths
# must be relative to the repository root. If no files are specified, everything
# is tested.
################################################################################
# Get the working directory to the repo root.
thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $?
topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $?
cd "${topdir}" || exit $?
# Run in parallel by default. Pass the `-n0` option for a single-process run.
# (the last `-n` option wins)
PYTEST_ARGS=( "-n=auto" "$@" )
source dev_tools/pypath || exit $?
pytest "${PYTEST_ARGS[@]}"
RESULT=$?
if [ "$RESULT" = 5 ]; then
echo "[exit 5] No tests collected, but ignored."
exit 0
fi
exit "$RESULT"