From a71e163f561464c38aa49ca3dee881770b727b5d Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 07:49:02 +0000 Subject: [PATCH 1/2] Add environment-agnostic scripts for running ctests and pytests --- ci/run_ctests.sh | 10 ++++++++++ ci/run_pylibraft_pytests.sh | 9 +++++++++ ci/run_raft_dask_pytests.sh | 9 +++++++++ ci/test_cpp.sh | 13 ++++++------- ci/test_python.sh | 21 ++++++++------------- 5 files changed, 42 insertions(+), 20 deletions(-) create mode 100755 ci/run_ctests.sh create mode 100755 ci/run_pylibraft_pytests.sh create mode 100755 ci/run_raft_dask_pytests.sh diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh new file mode 100755 index 0000000000..396f4573a0 --- /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/libraft/" ]; then + # Support customizing the ctests' install location + cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libraft/" + ctest --output-on-failure "$@" +fi diff --git a/ci/run_pylibraft_pytests.sh b/ci/run_pylibraft_pytests.sh new file mode 100755 index 0000000000..1167b89c5f --- /dev/null +++ b/ci/run_pylibraft_pytests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support invoking run_pylibraft_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/pylibraft/pylibraft + +pytest --cache-clear "$@" test diff --git a/ci/run_raft_dask_pytests.sh b/ci/run_raft_dask_pytests.sh new file mode 100755 index 0000000000..46cd211d2e --- /dev/null +++ b/ci/run_raft_dask_pytests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support invoking run_raft_dask_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/raft-dask/raft_dask + +pytest --cache-clear "$@" test diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 0f8efb171e..fb2d025f9c 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" @@ -31,13 +34,9 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e - +export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ # Run libraft gtests from libraft-tests package -cd "$CONDA_PREFIX"/bin/gtests/libraft -ctest -j8 --output-on-failure +./ci/run_ctests.sh -j8 && 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 cb6b7631e4..aae8ae03ea 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_python.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ + . /opt/conda/etc/profile.d/conda.sh rapids-logger "Generate Python testing dependencies" @@ -41,28 +44,20 @@ trap "EXITCODE=1" ERR set +e rapids-logger "pytest pylibraft" -pushd python/pylibraft/pylibraft -pytest \ - --cache-clear \ +./ci/run_pylibraft_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-pylibraft.xml" \ --cov-config=../.coveragerc \ --cov=pylibraft \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/pylibraft-coverage.xml" \ - --cov-report=term \ - test -popd + --cov-report=term rapids-logger "pytest raft-dask" -pushd python/raft-dask/raft_dask -pytest \ - --cache-clear \ +./ci/run_raft_dask_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-raft-dask.xml" \ --cov-config=../.coveragerc \ --cov=raft_dask \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/raft-dask-coverage.xml" \ - --cov-report=term \ - test -popd + --cov-report=term rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} From 5b8b37a8dcd968ad1a5d7b1e1c119bf4de932b7c Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 17:07:09 +0000 Subject: [PATCH 2/2] fail if gtests aren't installed --- ci/run_ctests.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh index 396f4573a0..f6d0ef26ef 100755 --- a/ci/run_ctests.sh +++ b/ci/run_ctests.sh @@ -3,8 +3,7 @@ set -euo pipefail -if [ -d "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libraft/" ]; then - # Support customizing the ctests' install location - cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libraft/" - ctest --output-on-failure "$@" -fi +# Support customizing the ctests' install location +cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libraft/" + +ctest --output-on-failure "$@"