Skip to content

Commit

Permalink
Add environment-agnostic scripts for running ctests and pytests (rapi…
Browse files Browse the repository at this point in the history
…dsai#2165)

This PR adds environment-agnostic `run_*_{ctests,pytests}.sh` scripts, and updates `test_*_{cpp,python}.sh` to call them.

The `test_*_{cpp,python}.sh` scripts assume they're running in our CI environment, and they do more than just run the tests.

This PR allows devs and downstream consumers to only run the tests, and skip the unrelated logic in `test_*_{cpp,python}.sh`.

Authors:
  - Paul Taylor (https://github.com/trxcllnt)

Approvers:
  - Jake Awe (https://github.com/AyodeAwe)

URL: rapidsai#2165
  • Loading branch information
trxcllnt authored Feb 27, 2024
1 parent da22f2f commit 435f7d6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
9 changes: 9 additions & 0 deletions ci/run_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libraft/"

ctest --output-on-failure "$@"
9 changes: 9 additions & 0 deletions ci/run_pylibraft_pytests.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions ci/run_raft_dask_pytests.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}
21 changes: 8 additions & 13 deletions ci/test_python.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}

0 comments on commit 435f7d6

Please sign in to comment.