From fa66b35921b7845ae8bb1a4ae475bbecdd1edd9c Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 05:54:35 +0000 Subject: [PATCH 1/7] Add environment-agnostic scripts for running ctests and pytests --- ci/run_ctests.sh | 10 ++++++++++ ci/run_pytests.sh | 9 +++++++++ ci/test_cpp.sh | 11 ++++------- ci/test_python.sh | 14 ++++---------- 4 files changed, 27 insertions(+), 17 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 0000000000..069490facf --- /dev/null +++ b/ci/run_ctests.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support customizing the ctests' install location +cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" + +# Run BASIC_IO_TEST +./BASIC_IO_TEST diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh new file mode 100755 index 0000000000..73de68d03b --- /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/ + +pytest --cache-clear --verbose "$@" tests diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 8a4e540e9b..8cc69b7643 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. set -euo pipefail @@ -32,12 +32,9 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e - -# Run BASIC_IO_TEST -"$CONDA_PREFIX"/bin/tests/libkvikio/BASIC_IO_TEST +# Support invoking test_cpp.sh outside the script directory +"$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/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 91fa442599..865697af6f 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. set -euo pipefail @@ -36,21 +36,15 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e - rapids-logger "pytest kvikio" -pushd python/ -pytest \ - --cache-clear \ +# Support invoking test_python.sh outside the script directory +"$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/run_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-kvikio.xml" \ - --verbose \ --cov-config=.coveragerc \ --cov=kvikio \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/kvikio-coverage.xml" \ --cov-report=term \ - tests + && EXITCODE=$? || EXITCODE=$?; rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} From 39123446bb7ae8e09520533e503124de2f3b5e9a Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 06:25:09 +0000 Subject: [PATCH 2/7] use py.test --- ci/run_pytests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh index 73de68d03b..24ca69212a 100755 --- a/ci/run_pytests.sh +++ b/ci/run_pytests.sh @@ -6,4 +6,4 @@ set -euo pipefail # Support invoking run_pytests.sh outside the script directory cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/ -pytest --cache-clear --verbose "$@" tests +py.test --cache-clear --verbose "$@" tests From 2dec32ab4ee754dea8c457636a5dd7ba63cae75b Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 06:26:59 +0000 Subject: [PATCH 3/7] check if libkvikio gtests dir exists before cd'ing --- ci/run_ctests.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh index 069490facf..5ec9d1d9a4 100755 --- a/ci/run_ctests.sh +++ b/ci/run_ctests.sh @@ -3,8 +3,9 @@ set -euo pipefail -# Support customizing the ctests' install location -cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" - -# Run BASIC_IO_TEST -./BASIC_IO_TEST +if [ -d "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" ]; then + # Support customizing the ctests' install location + cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" + # Run BASIC_IO_TEST + ./BASIC_IO_TEST +fi From 5f68d178247e0873ec1de6637c271b780309f2c9 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Tue, 6 Feb 2024 22:47:42 -0800 Subject: [PATCH 4/7] use python -m pytest --- ci/run_pytests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh index 24ca69212a..9e2e6509e8 100755 --- a/ci/run_pytests.sh +++ b/ci/run_pytests.sh @@ -6,4 +6,4 @@ set -euo pipefail # Support invoking run_pytests.sh outside the script directory cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/ -py.test --cache-clear --verbose "$@" tests +python -m pytest --cache-clear --verbose "$@" tests From cbe6aa70907a0d2ed9c8ca3884108e60c9c98922 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 07:11:19 +0000 Subject: [PATCH 5/7] use pytest binary --- ci/run_pytests.sh | 2 +- ci/test_python.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh index 9e2e6509e8..73de68d03b 100755 --- a/ci/run_pytests.sh +++ b/ci/run_pytests.sh @@ -6,4 +6,4 @@ set -euo pipefail # Support invoking run_pytests.sh outside the script directory cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/ -python -m pytest --cache-clear --verbose "$@" tests +pytest --cache-clear --verbose "$@" tests diff --git a/ci/test_python.sh b/ci/test_python.sh index 865697af6f..715758ec2c 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -3,6 +3,9 @@ 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" @@ -37,8 +40,7 @@ rapids-logger "Check GPU usage" nvidia-smi rapids-logger "pytest kvikio" -# Support invoking test_python.sh outside the script directory -"$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/run_pytests.sh \ +./run_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-kvikio.xml" \ --cov-config=.coveragerc \ --cov=kvikio \ From f8dfb7590e3ef5140b92f206802441582bb6e1f8 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 07:31:03 +0000 Subject: [PATCH 6/7] cd to the repo root --- ci/test_python.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 715758ec2c..0869e1a3a0 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -4,7 +4,7 @@ set -euo pipefail # Support invoking test_python.sh outside the script directory -cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ . /opt/conda/etc/profile.d/conda.sh @@ -40,7 +40,7 @@ rapids-logger "Check GPU usage" nvidia-smi rapids-logger "pytest kvikio" -./run_pytests.sh \ +./ci/run_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-kvikio.xml" \ --cov-config=.coveragerc \ --cov=kvikio \ From fc991b48931c71542023d5a2be69560b5350f6bb Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 7 Feb 2024 17:07:01 +0000 Subject: [PATCH 7/7] fail if gtests aren't installed --- ci/run_ctests.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh index 5ec9d1d9a4..069490facf 100755 --- a/ci/run_ctests.sh +++ b/ci/run_ctests.sh @@ -3,9 +3,8 @@ set -euo pipefail -if [ -d "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" ]; then - # Support customizing the ctests' install location - cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" - # Run BASIC_IO_TEST - ./BASIC_IO_TEST -fi +# Support customizing the ctests' install location +cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/tests/libkvikio/" + +# Run BASIC_IO_TEST +./BASIC_IO_TEST