Skip to content

Commit 5786b5c

Browse files
committed
Make sure CI install pytest (via pip3) and wrap pytest invocation with CMake option
1 parent 698d319 commit 5786b5c

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
shell: bash
6666
run: |
6767
sudo yum install --setopt=tsflags=nodocs -y eigen3-devel ceres-solver-devel json-devel
68-
sudo python -m pip install nanobind
68+
sudo python -m pip3 install nanobind pytest
6969
7070
- name: Configure CMake
7171
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
@@ -153,7 +153,7 @@ jobs:
153153
shell: bash
154154
run: |
155155
sudo yum install --setopt=tsflags=nodocs -y eigen3-devel ceres-solver-devel json-devel
156-
sudo python -m pip install nanobind
156+
sudo python -m pip3 install nanobind pytest
157157
158158
- name: Configure CMake
159159
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.

tests/CMakeLists.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,20 @@ add_test ( NAME Test_ImageConverter COMMAND Test_ImageConverter )
202202

203203
################################################################################
204204
# Python tests
205-
find_program(PYTHON_EXECUTABLE python3)
206-
if(PYTHON_EXECUTABLE)
207-
add_test(
208-
NAME Test_Python_ImageConverter
209-
COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/python/test_image_converter.py -v
210-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
211-
)
212-
213-
# Set environment for Python test to find the compiled module
214-
set_tests_properties(Test_Python_ImageConverter PROPERTIES
215-
ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/bindings:$ENV{PYTHONPATH}"
216-
)
205+
if(RTA_BUILD_PYTHON_BINDINGS)
206+
find_program(PYTHON_EXECUTABLE python3)
207+
if(PYTHON_EXECUTABLE)
208+
add_test(
209+
NAME Test_Python_ImageConverter
210+
COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/python/test_image_converter.py -v
211+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
212+
)
213+
214+
# Set environment for Python test to find the compiled module
215+
set_tests_properties(Test_Python_ImageConverter PROPERTIES
216+
ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/src/bindings:$ENV{PYTHONPATH}"
217+
)
218+
endif()
217219
endif()
218220

219221
################################################################################

0 commit comments

Comments
 (0)