From 550fe5b5cb21b63446ae8d46cb5312e71d1c4a39 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 08:52:21 +0000 Subject: [PATCH] Add environment-agnostic scripts for running ctests and pytests --- ci/run_ctests.sh | 10 ++++++++++ ci/run_pytests.sh | 9 +++++++++ ci/test_cpp.sh | 28 ++++++++-------------------- ci/test_python.sh | 14 +++++--------- 4 files changed, 32 insertions(+), 29 deletions(-) create mode 100755 ci/run_ctests.sh create mode 100755 ci/run_pytests.sh diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh new file mode 100755 index 000000000..1087d141c --- /dev/null +++ b/ci/run_ctests.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +if [ -d "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libwholegraph/" ]; then + # Support customizing the ctests' install location + cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libwholegraph/" + find . -type f -executable -print0 | xargs -0 -r -t -n1 -P1 sh -c 'exec "$0"'; +fi diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh new file mode 100755 index 000000000..439969cb7 --- /dev/null +++ b/ci/run_pytests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support invoking run_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/pylibwholegraph/pylibwholegraph + +pytest --cache-clear --forked "$@" tests diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 281318047..0dd5626bc 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,8 +1,11 @@ #!/bin/bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. set -euo pipefail +# Support invoking test_cpp.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ + . /opt/conda/etc/profile.d/conda.sh rapids-logger "Generate C++ testing dependencies" @@ -32,25 +35,10 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e # Run libwholegraph tests from libwholegraph-tests package rapids-logger "Run tests" -INSTALLED_TEST_PATH=${CONDA_PREFIX}/bin/gtests/libwholegraph - -for file in "${INSTALLED_TEST_PATH}"/*; do - if [[ -x "$file" ]]; then - rapids-logger "Running: $file" - "$file" - exit_code=$? - - if [[ $exit_code -ne 0 ]]; then - echo "Test $file returned a non-zero exit code: $exit_code" - exit $exit_code - fi - fi -done - -exit 0 +./ci/run_ctests.sh && EXITCODE=$? || EXITCODE=$? + +rapids-logger "Test script exiting with value: $EXITCODE" +exit ${EXITCODE} diff --git a/ci/test_python.sh b/ci/test_python.sh index 2dff744e5..941ac38fd 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -1,8 +1,11 @@ #!/bin/bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. set -euo pipefail +# Support invoking test_cpp.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ + . /opt/conda/etc/profile.d/conda.sh ARCH=$(arch) @@ -50,16 +53,9 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -trap "EXITCODE=1" ERR -set +e rapids-logger "pytest pylibwholegraph" -PYLIBWHOLEGRAPH_INSTALL_PATH=`python -c 'import os; import pylibwholegraph; print(os.path.dirname(pylibwholegraph.__file__))'` -PYTEST_PATH=${PYLIBWHOLEGRAPH_INSTALL_PATH}/tests -pytest \ - --cache-clear \ - --forked \ - ${PYTEST_PATH} +./ci/run_pytests.sh && EXITCODE=$? || EXITCODE=$? echo "test_python is exiting with value: ${EXITCODE}" exit ${EXITCODE}