From 92c066b1e5c1986f6d779613b22e53f58f5236ac Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Mon, 30 Nov 2020 09:54:50 +0100 Subject: [PATCH] Modify test_QFINDTESTDATA to not leave files in source tree test_QFINDTESTDATA is a test which is built and run in the source tree. It tests usage of relative paths of the Ninja generator, which only occurs when building in the source tree, so this test cannot be done outside of the source tree. Developer's expectation is, however, that an out-of-source build does not change the source tree. Having "git status" showing differences after running the tests is irritating. This patch removes the in-source build files after executing the test. Change-Id: Ia9fd368c9d54b97a415b63254b45e17bc95ecf45 Reviewed-by: Craig Scott Reviewed-by: Alexandru Croitor --- tests/auto/cmake/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index e8a60840a6..45991a9058 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -108,23 +108,26 @@ _qt_internal_test_expect_pass(test_platform_defs_include) _qt_internal_test_expect_pass(test_qtmainwin_library) if (CMAKE_GENERATOR STREQUAL Ninja AND UNIX AND NOT WIN32) - make_directory("${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build") + set(qfindtestdata_build_dir "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build") add_test(test_QFINDTESTDATA ${CMAKE_CTEST_COMMAND} --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA" # Build in a subdir of the source dir. # This causes Ninja to use relative paths. - "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build" + "${qfindtestdata_build_dir}" --build-config "${CMAKE_BUILD_TYPE}" --build-generator "${CMAKE_GENERATOR}" --build-makeprogram "${CMAKE_MAKE_PROGRAM}" --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} ) - add_test(NAME run_test_QFINDTESTDATA COMMAND sh -c "cd \"${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build/tests\" && ./test_QFINDTESTDATA -v2") + set_tests_properties(test_QFINDTESTDATA PROPERTIES FIXTURES_SETUP QFINDTESTDATA) - set_property(TEST run_test_QFINDTESTDATA - PROPERTY DEPENDS test_QFINDTESTDATA - ) + add_test(NAME run_test_QFINDTESTDATA COMMAND sh -c "cd \"${qfindtestdata_build_dir}/tests\" && ./test_QFINDTESTDATA -v2") + set_tests_properties(run_test_QFINDTESTDATA PROPERTIES FIXTURES_REQUIRED QFINDTESTDATA) + + # source dir should be untouched by build, so remove build results + add_test(NAME cleanup_test_QFINDTESTDATA COMMAND sh -c "rm -rf \"${qfindtestdata_build_dir}\"") + set_tests_properties(cleanup_test_QFINDTESTDATA PROPERTIES FIXTURES_CLEANUP QFINDTESTDATA) endif() if (NOT NO_DBUS)