Skip to content

Commit e06dda8

Browse files
committed
Get rid of unsupported ENVIRONMENT_MODIFICATION
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
1 parent 3ba6d11 commit e06dda8

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

src/cmake/testing.cmake

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ set(OIIO_TESTSUITE_IMAGEDIR "${PROJECT_BINARY_DIR}/testsuite" CACHE PATH
2121
"Location of oiio-images, openexr-images, libtiffpic, etc.." )
2222

2323

24+
# Build a single ENVIRONMENT list entry "PYTHONPATH=..." for CTest. Prepends
25+
# prefix_dir to the value CMake saw in $ENV{PYTHONPATH} at configure time (so
26+
# local PYTHONPATH is preserved when it was set for the cmake run).
27+
function (oiio_tests_pythonpath_env_entry out_var prefix_dir)
28+
if (WIN32)
29+
set (_separator ";")
30+
else ()
31+
set (_separator ":")
32+
endif ()
33+
set (_pythonpath "${prefix_dir}")
34+
if (DEFINED ENV{PYTHONPATH} AND NOT "$ENV{PYTHONPATH}" STREQUAL "")
35+
set (_pythonpath "${prefix_dir}${_separator}$ENV{PYTHONPATH}")
36+
endif ()
37+
set (${out_var} "PYTHONPATH=${_pythonpath}" PARENT_SCOPE)
38+
endfunction ()
39+
2440

2541
# oiio_add_tests() - add a set of test cases.
2642
#
@@ -33,7 +49,6 @@ set(OIIO_TESTSUITE_IMAGEDIR "${PROJECT_BINARY_DIR}/testsuite" CACHE PATH
3349
# [ DISABLEVAR variable_name ... ]
3450
# [ SUFFIX suffix ]
3551
# [ ENVIRONMENT "VAR=value" ... ]
36-
# [ ENVIRONMENT_MODIFICATION "VAR=op:value" ... ]
3752
# )
3853
#
3954
# The optional argument IMAGEDIR is used to check whether external test images
@@ -56,12 +71,8 @@ set(OIIO_TESTSUITE_IMAGEDIR "${PROJECT_BINARY_DIR}/testsuite" CACHE PATH
5671
# The optional ENVIRONMENT is a list of environment variables to set for the
5772
# test.
5873
#
59-
# The optional ENVIRONMENT_MODIFICATION is a list of environment variable
60-
# modifications in the format accepted by the CTest ENVIRONMENT_MODIFICATION
61-
# property.
62-
#
6374
macro (oiio_add_tests)
64-
cmake_parse_arguments (_ats "" "SUFFIX;TESTNAME" "URL;IMAGEDIR;LABEL;FOUNDVAR;ENABLEVAR;DISABLEVAR;ENVIRONMENT;ENVIRONMENT_MODIFICATION" ${ARGN})
75+
cmake_parse_arguments (_ats "" "SUFFIX;TESTNAME" "URL;IMAGEDIR;LABEL;FOUNDVAR;ENABLEVAR;DISABLEVAR;ENVIRONMENT" ${ARGN})
6576
# Arguments: <prefix> <options> <one_value_keywords> <multi_value_keywords> args...
6677
set (_ats_testdir "${OIIO_TESTSUITE_IMAGEDIR}/${_ats_IMAGEDIR}")
6778
# If there was a FOUNDVAR param specified and that variable name is
@@ -136,11 +147,6 @@ macro (oiio_add_tests)
136147
"OIIO_TESTSUITE_CUR=${_testdir}"
137148
"Python_EXECUTABLE=${Python3_EXECUTABLE}"
138149
${_ats_ENVIRONMENT})
139-
if (_ats_ENVIRONMENT_MODIFICATION)
140-
set_property(TEST ${_testname} APPEND PROPERTY
141-
ENVIRONMENT_MODIFICATION
142-
${_ats_ENVIRONMENT_MODIFICATION})
143-
endif ()
144150
if (NOT ${_ats_testdir} STREQUAL "")
145151
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
146152
"OIIO_TESTSUITE_IMAGEDIR=${_ats_testdir}")
@@ -238,8 +244,10 @@ macro (oiio_add_all_tests)
238244
# Python interpreter itself won't be linked with the right asan
239245
# libraries to run correctly.
240246
if (USE_PYTHON AND NOT BUILD_OIIOUTIL_ONLY AND NOT SANITIZE)
241-
set (pybind11_python_path_mod
242-
"PYTHONPATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib/python/site-packages")
247+
oiio_tests_pythonpath_env_entry (_pybind_tests_pythonpath
248+
"${CMAKE_BINARY_DIR}/lib/python/site-packages")
249+
oiio_tests_pythonpath_env_entry (_nanobind_tests_pythonpath
250+
"${CMAKE_BINARY_DIR}/lib/python/nanobind")
243251
set (nanobind_python_tests
244252
python-imagespec
245253
python-paramlist
@@ -260,13 +268,13 @@ macro (oiio_add_all_tests)
260268
python-texturesys
261269
python-typedesc
262270
filters
263-
ENVIRONMENT_MODIFICATION ${pybind11_python_path_mod}
271+
ENVIRONMENT "${_pybind_tests_pythonpath}"
264272
)
265273
# These Python tests also need access to oiio-images
266274
oiio_add_tests (
267275
python-imageinput python-imagebufalgo
268276
IMAGEDIR oiio-images
269-
ENVIRONMENT_MODIFICATION ${pybind11_python_path_mod}
277+
ENVIRONMENT "${_pybind_tests_pythonpath}"
270278
)
271279
else ()
272280
set (nanobind_python_test_suffix "")
@@ -276,8 +284,7 @@ macro (oiio_add_all_tests)
276284
oiio_add_tests (
277285
${nanobind_python_tests}
278286
SUFFIX ${nanobind_python_test_suffix}
279-
ENVIRONMENT_MODIFICATION
280-
"PYTHONPATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib/python/nanobind"
287+
ENVIRONMENT "${_nanobind_tests_pythonpath}"
281288
)
282289
endif ()
283290
endif ()

0 commit comments

Comments
 (0)