ci: run-pytest.sh: allow script to run locally

Currently, run-pytest.sh won't run locally outside of a pipeline
because it can't find the `setup-test-env.sh` which provides necessary
functions.

Add a default value for the SCRIPTS_DIR so that run-pytest can find and
run the setup-test-env.sh and be run locally outside of a pipeline.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32602>
This commit is contained in:
Deborah Brouwer
2024-12-11 14:19:28 -08:00
committed by Marge Bot
parent 3471b47574
commit e274d27be5

View File

@@ -7,16 +7,29 @@
# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
# shellcheck disable=SC2086 # quoting PYTEST_VERBOSE makes us pass an empty path
. "${SCRIPTS_DIR}/setup-test-env.sh"
set -eu
if [ -z "${SCRIPTS_DIR:-}" ]; then
SCRIPTS_DIR="$(dirname "${0}")"
fi
if [ -z "${CI_JOB_STARTED_AT:-}" ]; then
CI_JOB_STARTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ) # isoformat
fi
source "${SCRIPTS_DIR}/setup-test-env.sh"
section_start pytest_setup "Setting up pytest environment"
set -exu
if [ -z "${CI_PROJECT_DIR:-}" ]; then
CI_PROJECT_DIR="$(dirname "${0}")/../"
fi
if [ -z "${CI_JOB_TIMEOUT:-}" ]; then
# Export this default value, 1 hour in seconds, to test the lava job submitter
export CI_JOB_TIMEOUT=3600
fi
if [ -z "${MESA_PYTEST_VENV:-}" ]; then
MESA_PYTEST_VENV="${CI_PROJECT_DIR}/.venv-pytest"
fi