Skip to content

Commit

Permalink
Use a centralized directory for files created by ctest
Browse files Browse the repository at this point in the history
Defines a QGIS_TEST_TMP_DIR variable in top-level CMakeLists.txt
and then defines QGIS_CUSTOM_CONFIG_PATH and TMPDIR to be under
that directory for individual tests.

Closes qgisGH-50587
Closes qgisGH-48884
  • Loading branch information
strk committed May 29, 2024
1 parent dfd4aad commit c2e9ab5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,8 @@ if (WITH_ASTYLE)
endif()

if (ENABLE_TESTS)
set(QGIS_TEST_TMP_DIR "${CMAKE_BINARY_DIR}/tmp")
message (STATUS "Ctest Temp Directory set to: ${QGIS_TEST_TMP_DIR}")
add_subdirectory(tests)
set (CTEST_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin" )
message (STATUS "Ctest Binary Directory set to: ${CTEST_BINARY_DIRECTORY}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/UsePythonTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ macro(ADD_PYTHON_TEST TESTNAME FILENAME)

set_tests_properties(${TESTNAME} PROPERTIES
FIXTURES_REQUIRED SOURCETREE
ENVIRONMENT "TMPDIR=${CMAKE_BINARY_DIR}/tmp"
ENVIRONMENT "TMPDIR=${QGIS_TEST_TMP_DIR};QGIS_CUSTOM_CONFIG_PATH=${QGIS_TEST_TMP_DIR}/config"
)

endmacro(ADD_PYTHON_TEST)
3 changes: 1 addition & 2 deletions tests/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ if (ENABLE_TESTS)
set_tests_properties(${TESTNAME} PROPERTIES LABELS ${ARG_QGIS_TEST_LABELS})
endif()

# TODO: put the temp dir and custom config path under the build dir
set_tests_properties(${TESTNAME} PROPERTIES
FIXTURES_REQUIRED SOURCETREE
ENVIRONMENT "QGIS_CUSTOM_CONFIG_PATH=${CMAKE_BINARY_DIR}/tmp/qgis-tests/config"
ENVIRONMENT "TMPDIR=${QGIS_TEST_TMP_DIR};QGIS_CUSTOM_CONFIG_PATH=${QGIS_TEST_TMP_DIR}/config"
)

target_compile_definitions(${TESTNAME} PRIVATE "CMAKE_SOURCE_DIR=\"${CMAKE_SOURCE_DIR}\"")
Expand Down

0 comments on commit c2e9ab5

Please sign in to comment.