From fd2ff73b820079e4670f1348c5ab8f5c61143b34 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 3 Sep 2021 11:02:54 +0200 Subject: cmake: tests: Add build-python path to PYTHONPATH This is more of an expressive change than a functional change; Python seems to add this path to the PYTHONPATH anyway, at least for some systems. We neverless make this change because: - It's more explicit/expressive. When tests are run, the PYTHONPATH env variable is printed, and it now contains this path where it should be, right at the front. People reading the ctest/python.unittest output now get told explicitly which path we mean. - This guarantees that this path is added, even if Python/unittest should behave differently on other systems or versions. To clarify: When running unit tests, we want to run the Python code from build/python, not the installed version. The latter may not yet exist, and if it does, it's not the version we are editing. --- host/cmake/Modules/UHDUnitTest.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'host/cmake/Modules') diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake index 519be9ca0..4e6651fd9 100644 --- a/host/cmake/Modules/UHDUnitTest.cmake +++ b/host/cmake/Modules/UHDUnitTest.cmake @@ -133,9 +133,12 @@ function(UHD_ADD_PYTEST test_name) # Include ${CMAKE_BINARY_DIR}/utils/ for testing the python utils if(APPLE) set_tests_properties(${test_name} PROPERTIES - ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/") + ENVIRONMENT + "DYLD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/") else() set_tests_properties(${test_name} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/") + ENVIRONMENT + "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib/;PYTHONPATH=${UHD_BINARY_DIR}/python:${CMAKE_SOURCE_DIR}/tests/common:${CMAKE_BINARY_DIR}/utils/" + ) endif() endfunction(UHD_ADD_PYTEST) -- cgit v1.2.3