Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Add environment-agnostic scripts for running ctests and pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Feb 7, 2024
1 parent dca9fd6 commit 550fe5b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
10 changes: 10 additions & 0 deletions ci/run_ctests.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions ci/run_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_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/pylibwholegraph/pylibwholegraph

pytest --cache-clear --forked "$@" tests
28 changes: 8 additions & 20 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 @@ -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}
14 changes: 5 additions & 9 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_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

. /opt/conda/etc/profile.d/conda.sh

ARCH=$(arch)
Expand Down Expand Up @@ -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}

0 comments on commit 550fe5b

Please sign in to comment.