Skip to content

Commit 0f2b31d

Browse files
authored
Merge pull request #358 from Sichao25/yus/ci
Apply pytest unit testing
2 parents 61a9a65 + 868c072 commit 0f2b31d

14 files changed

Lines changed: 544 additions & 1325 deletions

.github/workflows/cmake-test.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
if: matrix.python_api == 'ON'
6868
run: |
6969
sudo apt-get install -yq python3 python3-pip python3-dev python3-pybind11 pybind11-dev
70-
pip3 install numpy
70+
pip3 install numpy pytest
7171
7272
- uses: actions/checkout@v4
7373

@@ -288,12 +288,8 @@ jobs:
288288
run: |
289289
export PYTHONPATH=${{ runner.temp }}/build-pcms/install/lib/python3.12/site-packages:$PYTHONPATH
290290
export PYTHONPATH=${{ runner.temp }}/build-omega_h/install/lib/python/dist-packages:$PYTHONPATH
291-
cd ${{ github.workspace }}/src/pcms/pythonapi
292-
python3 test_file_io.py
293-
python3 test_omega_h_field.py
294-
python3 test_uniform_grid_field.py
295-
python3 test_field_copy.py
296-
python3 test_mls_interpolation.py
291+
cd ${{ github.workspace }}
292+
pytest -v --tb=short -p no:cacheprovider
297293
298294
- name: Test PCMS Installation
299295
if: matrix.python_api == 'OFF'

.github/workflows/self-hosted.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
#module load openblas/0.3.23-wqm7iud
4949
module load netlib-lapack/3.11.0-b22mgwg #netlib-lapack includes blas
5050
module load netlib-scalapack/2.2.0-fzd4jvl
51+
module load python py-pytest py-numpy
5152
set -e
5253
EOF
5354
@@ -98,13 +99,13 @@ jobs:
9899
cmake --build $bdir -j 4
99100
ctest --test-dir $bdir --output-on-failure
100101
101-
# Build pcms with PETSc
102+
# Build pcms with PETSc and python enabled
102103
cmake -S ${{github.workspace}}/pcms_${{ github.event.id }} -B $bdir \
103104
-DCMAKE_CXX_COMPILER=`which mpicxx` \
104105
-DCMAKE_C_COMPILER=`which mpicc` \
105106
-DCMAKE_Fortran_COMPILER=`which mpifort`\
106107
-DPCMS_TIMEOUT=20 \
107-
-DCMAKE_BUILD_TYPE=Release \
108+
-DCMAKE_BUILD_TYPE=DEBUG \
108109
-DCatch2_DIR=$DEPENDENCY_DIR/Catch2/install/lib64/cmake/Catch2/ \
109110
-Dmeshfields_DIR=$DEPENDENCY_DIR/${DEVICE_ARCH}/meshFields/install/lib64/cmake/meshfields \
110111
-DOmega_h_DIR=$DEPENDENCY_DIR/${DEVICE_ARCH}/omega_h/install/lib64/cmake/Omega_h/ \
@@ -116,14 +117,20 @@ jobs:
116117
-DKokkos_DIR=$DEPENDENCY_DIR/${DEVICE_ARCH}/kokkos/install/lib64/cmake/Kokkos/ \
117118
-DKokkosKernels_DIR=$DEPENDENCY_DIR/${DEVICE_ARCH}/kokkos-kernels/install/lib64/cmake/KokkosKernels/ \
118119
-DBUILD_TESTING=ON \
120+
-DPCMS_ENABLE_Python=ON \
119121
-DPCMS_ENABLE_PETSC=ON \
120122
-DPETSC_ARCH="" \
121123
-DPETSC_DIR=$DEPENDENCY_DIR/${DEVICE_ARCH}/petsc/install \
124+
-Dpybind11_ROOT=$DEPENDENCY_DIR/pybind11/install \
122125
-DPCMS_ENABLE_SPDLOG=OFF
123126
124127
cmake --build $bdir -j 4
125128
ctest --test-dir $bdir --output-on-failure
126129
130+
export PYTHONPATH=$DEPENDENCY_DIR/${DEVICE_ARCH}/omega_h/install/lib64/python./site-packages:$bdir/src/pcms/pythonapi:$PYTHONPATH
131+
export LD_LIBRARY_PATH=$DEPENDENCY_DIR/${DEVICE_ARCH}/omega_h/install/lib64:$LD_LIBRARY_PATH
132+
pytest -v -p no:cacheprovider ${{github.workspace}}/pcms_${{ github.event.id }}/test/python
133+
127134
128135
- name: Save Result Link
129136
if: ${{ !cancelled() }} #prepare report unless the job was cancelled

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ version = "0.4.0"
88

99
[tool.scikit-build.cmake.define]
1010
PCMS_ENABLE_Python = true
11+
12+
[tool.pytest.ini_options]
13+
testpaths = ["test/python"]
14+
python_files = "test_*.py"
15+
python_classes = "Test*"
16+
python_functions = "test_*"
17+
addopts = "--strict-markers"

src/pcms/pythonapi/test_field_copy.py

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)