From 0e434fcf0428f43dcc5f540ca0a61e078c9f4b4c Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 20 Jul 2017 22:35:05 +0200 Subject: Autogen: Move repeated tests to new QtAutogenRerun test By moving QtAutogen tests that run repeatedly to a new QtAutogenRerun test, the `ctest -R Qt[45]Autogen -j4` call runs approximately 25% faster. --- Tests/CMakeLists.txt | 39 +++- Tests/QtAutogen/CMakeLists.txt | 203 ----------------- Tests/QtAutogen/mocPlugin/CMakeLists.txt | 33 --- Tests/QtAutogen/mocPlugin/StyleA.cpp | 6 - Tests/QtAutogen/mocPlugin/StyleA.hpp | 17 -- Tests/QtAutogen/mocPlugin/StyleA.json | 1 - Tests/QtAutogen/mocPlugin/StyleA_Custom.json | 1 - Tests/QtAutogen/mocPlugin/StyleB.cpp | 6 - Tests/QtAutogen/mocPlugin/StyleB.hpp | 17 -- Tests/QtAutogen/mocPlugin/StyleC.cpp | 6 - Tests/QtAutogen/mocPlugin/StyleC.hpp | 17 -- Tests/QtAutogen/mocPlugin/StyleCommon.hpp | 7 - Tests/QtAutogen/mocPlugin/StyleD.cpp | 6 - Tests/QtAutogen/mocPlugin/StyleD.hpp | 17 -- Tests/QtAutogen/mocPlugin/StyleE.cpp | 6 - Tests/QtAutogen/mocPlugin/StyleE.hpp | 17 -- Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json | 1 - .../QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json | 1 - Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json | 1 - Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json | 1 - Tests/QtAutogen/mocPlugin/main.cpp | 6 - Tests/QtAutogen/mocRerun/CMakeLists.txt | 35 --- Tests/QtAutogen/mocRerun/input.txt | 1 - Tests/QtAutogen/mocRerun/main.cpp.in | 18 -- Tests/QtAutogen/mocRerun/res1.qrc | 5 - Tests/QtAutogen/mocRerun/test1a.h.in | 8 - Tests/QtAutogen/mocRerun/test1b.h.in | 7 - Tests/QtAutogen/rccDepends/CMakeLists.txt | 35 --- Tests/QtAutogen/rccDepends/main.cpp | 5 - Tests/QtAutogen/rccDepends/res/input1.txt.in | 1 - Tests/QtAutogen/rccDepends/res/input2.txt.in | 1 - Tests/QtAutogen/rccDepends/res1a.qrc.in | 5 - Tests/QtAutogen/rccDepends/res1b.qrc.in | 6 - Tests/QtAutogen/rccDepends/res2a.qrc.in | 5 - Tests/QtAutogen/rccDepends/res2b.qrc.in | 6 - Tests/QtAutogenRerun/CMakeLists.txt | 239 +++++++++++++++++++++ Tests/QtAutogenRerun/defines_test/CMakeLists.txt | 4 + Tests/QtAutogenRerun/defines_test/defines_test.cpp | 38 ++++ Tests/QtAutogenRerun/dummy.cpp | 5 + Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt | 33 +++ Tests/QtAutogenRerun/mocPlugin/StyleA.cpp | 6 + Tests/QtAutogenRerun/mocPlugin/StyleA.hpp | 17 ++ Tests/QtAutogenRerun/mocPlugin/StyleA.json | 1 + Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json | 1 + Tests/QtAutogenRerun/mocPlugin/StyleB.cpp | 6 + Tests/QtAutogenRerun/mocPlugin/StyleB.hpp | 17 ++ Tests/QtAutogenRerun/mocPlugin/StyleC.cpp | 6 + Tests/QtAutogenRerun/mocPlugin/StyleC.hpp | 17 ++ Tests/QtAutogenRerun/mocPlugin/StyleCommon.hpp | 7 + Tests/QtAutogenRerun/mocPlugin/StyleD.cpp | 6 + Tests/QtAutogenRerun/mocPlugin/StyleD.hpp | 17 ++ Tests/QtAutogenRerun/mocPlugin/StyleE.cpp | 6 + Tests/QtAutogenRerun/mocPlugin/StyleE.hpp | 17 ++ Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json | 1 + .../mocPlugin/jsonIn/StyleB_Custom.json | 1 + Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json | 1 + Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json | 1 + Tests/QtAutogenRerun/mocPlugin/main.cpp | 6 + Tests/QtAutogenRerun/mocRerun/CMakeLists.txt | 35 +++ Tests/QtAutogenRerun/mocRerun/input.txt | 1 + Tests/QtAutogenRerun/mocRerun/main.cpp.in | 18 ++ Tests/QtAutogenRerun/mocRerun/res1.qrc | 5 + Tests/QtAutogenRerun/mocRerun/test1a.h.in | 8 + Tests/QtAutogenRerun/mocRerun/test1b.h.in | 7 + Tests/QtAutogenRerun/rccDepends/CMakeLists.txt | 35 +++ Tests/QtAutogenRerun/rccDepends/main.cpp | 5 + Tests/QtAutogenRerun/rccDepends/res/input1.txt.in | 1 + Tests/QtAutogenRerun/rccDepends/res/input2.txt.in | 1 + Tests/QtAutogenRerun/rccDepends/res1a.qrc.in | 5 + Tests/QtAutogenRerun/rccDepends/res1b.qrc.in | 6 + Tests/QtAutogenRerun/rccDepends/res2a.qrc.in | 5 + Tests/QtAutogenRerun/rccDepends/res2b.qrc.in | 6 + 72 files changed, 627 insertions(+), 511 deletions(-) delete mode 100644 Tests/QtAutogen/mocPlugin/CMakeLists.txt delete mode 100644 Tests/QtAutogen/mocPlugin/StyleA.cpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleA.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleA.json delete mode 100644 Tests/QtAutogen/mocPlugin/StyleA_Custom.json delete mode 100644 Tests/QtAutogen/mocPlugin/StyleB.cpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleB.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleC.cpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleC.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleCommon.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleD.cpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleD.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleE.cpp delete mode 100644 Tests/QtAutogen/mocPlugin/StyleE.hpp delete mode 100644 Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json delete mode 100644 Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json delete mode 100644 Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json delete mode 100644 Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json delete mode 100644 Tests/QtAutogen/mocPlugin/main.cpp delete mode 100644 Tests/QtAutogen/mocRerun/CMakeLists.txt delete mode 100644 Tests/QtAutogen/mocRerun/input.txt delete mode 100644 Tests/QtAutogen/mocRerun/main.cpp.in delete mode 100644 Tests/QtAutogen/mocRerun/res1.qrc delete mode 100644 Tests/QtAutogen/mocRerun/test1a.h.in delete mode 100644 Tests/QtAutogen/mocRerun/test1b.h.in delete mode 100644 Tests/QtAutogen/rccDepends/CMakeLists.txt delete mode 100644 Tests/QtAutogen/rccDepends/main.cpp delete mode 100644 Tests/QtAutogen/rccDepends/res/input1.txt.in delete mode 100644 Tests/QtAutogen/rccDepends/res/input2.txt.in delete mode 100644 Tests/QtAutogen/rccDepends/res1a.qrc.in delete mode 100644 Tests/QtAutogen/rccDepends/res1b.qrc.in delete mode 100644 Tests/QtAutogen/rccDepends/res2a.qrc.in delete mode 100644 Tests/QtAutogen/rccDepends/res2b.qrc.in create mode 100644 Tests/QtAutogenRerun/CMakeLists.txt create mode 100644 Tests/QtAutogenRerun/defines_test/CMakeLists.txt create mode 100644 Tests/QtAutogenRerun/defines_test/defines_test.cpp create mode 100644 Tests/QtAutogenRerun/dummy.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleA.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleA.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleA.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleB.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleB.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleC.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleC.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleCommon.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleD.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleD.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleE.cpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/StyleE.hpp create mode 100644 Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json create mode 100644 Tests/QtAutogenRerun/mocPlugin/main.cpp create mode 100644 Tests/QtAutogenRerun/mocRerun/CMakeLists.txt create mode 100644 Tests/QtAutogenRerun/mocRerun/input.txt create mode 100644 Tests/QtAutogenRerun/mocRerun/main.cpp.in create mode 100644 Tests/QtAutogenRerun/mocRerun/res1.qrc create mode 100644 Tests/QtAutogenRerun/mocRerun/test1a.h.in create mode 100644 Tests/QtAutogenRerun/mocRerun/test1b.h.in create mode 100644 Tests/QtAutogenRerun/rccDepends/CMakeLists.txt create mode 100644 Tests/QtAutogenRerun/rccDepends/main.cpp create mode 100644 Tests/QtAutogenRerun/rccDepends/res/input1.txt.in create mode 100644 Tests/QtAutogenRerun/rccDepends/res/input2.txt.in create mode 100644 Tests/QtAutogenRerun/rccDepends/res1a.qrc.in create mode 100644 Tests/QtAutogenRerun/rccDepends/res1b.qrc.in create mode 100644 Tests/QtAutogenRerun/rccDepends/res2a.qrc.in create mode 100644 Tests/QtAutogenRerun/rccDepends/res2b.qrc.in diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 34418c5..13d796e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1285,12 +1285,28 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=5 ${QtAutogen_BUILD_OPTIONS} --test-command ${run_autogen_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen") + add_test(NAME Qt5AutogenRerun COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutogenRerun" + "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun" + ${build_generator_args} + --build-project QtAutogenRerun + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=5 + ${QtAutogen_BUILD_OPTIONS} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutogenRerun") + add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" @@ -1315,12 +1331,28 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 ${QtAutogen_BUILD_OPTIONS} --test-command ${run_autogen_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen") + add_test(NAME Qt4AutogenRerun COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutogenRerun" + "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun" + ${build_generator_args} + --build-project QtAutogenRerun + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun" + --force-new-ctest-process + --build-options ${build_options} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 + ${QtAutogen_BUILD_OPTIONS} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutogenRerun") + add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface" @@ -1330,7 +1362,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface" --force-new-ctest-process --build-options ${build_options} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4 + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DQT_TEST_VERSION=4 --test-command ${run_autouic_test} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface") diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index b3e83fd..5064d26 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -2,13 +2,6 @@ cmake_minimum_required(VERSION 3.9) cmake_policy(SET CMP0071 NEW) project(QtAutogen) -# Tell find_package(Qt5) where to find Qt. -if(QT_QMAKE_EXECUTABLE) - get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) - get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) - set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) -endif() - if (QT_TEST_VERSION STREQUAL 4) find_package(Qt4 REQUIRED) @@ -108,132 +101,6 @@ set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) -# -- Test -# When a file listed in a .qrc file changes the target must be rebuilt -set(timeformat "%Y%j%H%M%S") -set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends") -set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends") -configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -try_compile(RCC_DEPENDS - "${RCC_DEPENDS_BIN}" - "${RCC_DEPENDS_SRC}" - rccDepends - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList ENCODING UTF-8) -list(GET targetList 0 rccDependsBin) -file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}") -# Sleep, touch regular qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!") -endif() -# Sleep, update regular qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}") -if (NOT timeStep2 GREATER timeStep1) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!") -endif() -# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}") -if (NOT timeStep3 GREATER timeStep2) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!") -endif() -# Sleep, touch generated qrc input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}") -if (NOT timeStep4 GREATER timeStep3) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!") -endif() -# Sleep, update generated qrc file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Sixth build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}") -if (NOT timeStep5 GREATER timeStep4) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!") -endif() -# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. -execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Seventh build of rccDepends failed.") -endif() -file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}") -if (NOT timeStep6 GREATER timeStep5) - message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!") -endif() - - -# -- Test -# Ensure a repeated build succeeds when a header containing a QObject changes -set(timeformat "%Y%j%H%M%S") -configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY) -try_compile(MOC_RERUN - "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun" - mocRerun - CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" - "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output -) -if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") -endif() -# Get name and timestamp of the output binary -file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List ENCODING UTF-8) -list(GET target1List 0 binFile) -file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") -# Change file content and rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" - RESULT_VARIABLE mocRerun_result - ) -if (mocRerun_result) - message(SEND_ERROR "Second build of mocRerun failed.") -endif() -# Compare timestamps -file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") -if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${binFile}) should have changed in the first step!") -endif() # -- Test # Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target @@ -322,76 +189,6 @@ if(ALLOW_WRAP_CPP) endif() # -- Test -# Tests Q_PLUGIN_METADATA json file change detection -if (NOT QT_TEST_VERSION STREQUAL 4) - try_compile(MOC_PLUGIN - "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin" - "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin" - mocPlugin - CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" - "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" - OUTPUT_VARIABLE output - ) - if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") - endif() - - set(timeformat "%Y%j%H%M%S") - set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin") - set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin") - find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) - - file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") - file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - - # Ensure that the timestamp will change and change the json files - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - - file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") - file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") - file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") - file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") - - if (plAAfter GREATER plABefore) - message(SEND_ERROR "file (${plAFile}) should not have changed!") - endif() - if (plBAfter GREATER plBBefore) - message(SEND_ERROR "file (${plBFile}) should not have changed!") - endif() - if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") - endif() - if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") - endif() - - # Test custom macro - file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") - file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) - configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") - configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") - file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") - if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") - endif() - if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") - endif() - -endif() - -# -- Test # Tests various .ui include directories add_subdirectory(uicInclude) diff --git a/Tests/QtAutogen/mocPlugin/CMakeLists.txt b/Tests/QtAutogen/mocPlugin/CMakeLists.txt deleted file mode 100644 index 9b224fb..0000000 --- a/Tests/QtAutogen/mocPlugin/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -project(mocPlugin CXX) - -set(CMAKE_AUTOMOC_DEPEND_FILTERS - "A_CUSTOM_MACRO" - "[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\"" - ) - -if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") -endif() -find_package(Qt5Widgets REQUIRED) - -if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) - add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) -endif() - -configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json) -configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) -configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json) -configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json) - -# Enable automoc -set(CMAKE_AUTOMOC TRUE) - -include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles") -link_libraries(Qt5::Widgets) - -add_library(PlugA STATIC StyleA.cpp) -add_library(PlugB STATIC StyleB.cpp) -add_library(PlugC STATIC StyleC.cpp) -add_library(PlugD STATIC StyleD.cpp) -add_library(PlugE STATIC StyleE.cpp) diff --git a/Tests/QtAutogen/mocPlugin/StyleA.cpp b/Tests/QtAutogen/mocPlugin/StyleA.cpp deleted file mode 100644 index b5e8753..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleA.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleA.hpp" - -QStyle* StyleA::create(const QString& key) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocPlugin/StyleA.hpp b/Tests/QtAutogen/mocPlugin/StyleA.hpp deleted file mode 100644 index 1b6154d..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleA.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEA_HPP -#define STYLEA_HPP - -#include "StyleCommon.hpp" -#include - -class StyleA : public QStylePlugin -{ - Q_OBJECT - // Json file in local directory - Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json") - A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleA.json b/Tests/QtAutogen/mocPlugin/StyleA.json deleted file mode 100644 index cc33953..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleA.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "Starbuster" ] } diff --git a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json b/Tests/QtAutogen/mocPlugin/StyleA_Custom.json deleted file mode 100644 index cc33953..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "Starbuster" ] } diff --git a/Tests/QtAutogen/mocPlugin/StyleB.cpp b/Tests/QtAutogen/mocPlugin/StyleB.cpp deleted file mode 100644 index 17d4400..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleB.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleB.hpp" - -QStyle* StyleB::create(const QString& key) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocPlugin/StyleB.hpp b/Tests/QtAutogen/mocPlugin/StyleB.hpp deleted file mode 100644 index 163c9b2..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleB.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEB_HPP -#define STYLEB_HPP - -#include "StyleCommon.hpp" -#include - -class StyleB : public QStylePlugin -{ - Q_OBJECT - // Json file in local subdirectory - Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json") - A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleC.cpp b/Tests/QtAutogen/mocPlugin/StyleC.cpp deleted file mode 100644 index 37e7564..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleC.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleC.hpp" - -QStyle* StyleC::create(const QString& key) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocPlugin/StyleC.hpp b/Tests/QtAutogen/mocPlugin/StyleC.hpp deleted file mode 100644 index 52a887a..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleC.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEC_HPP -#define STYLEC_HPP - -#include "StyleCommon.hpp" -#include - -class StyleC : public QStylePlugin -{ - Q_OBJECT - // Json file in global root directory - Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json") - A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp b/Tests/QtAutogen/mocPlugin/StyleCommon.hpp deleted file mode 100644 index f1a7ec6..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef STYLECOMMON_HPP -#define STYLECOMMON_HPP - -// Empty test macro definition -#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations) - -#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleD.cpp b/Tests/QtAutogen/mocPlugin/StyleD.cpp deleted file mode 100644 index 7e4b121..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleD.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleD.hpp" - -QStyle* StyleD::create(const QString& key) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocPlugin/StyleD.hpp b/Tests/QtAutogen/mocPlugin/StyleD.hpp deleted file mode 100644 index df8a439..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleD.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLED_HPP -#define STYLED_HPP - -#include "StyleCommon.hpp" -#include - -class StyleD : public QStylePlugin -{ - Q_OBJECT - // Json file in global sub director - Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json") - A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/StyleE.cpp b/Tests/QtAutogen/mocPlugin/StyleE.cpp deleted file mode 100644 index 8fc9a7f..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleE.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleE.hpp" - -QStyle* StyleE::create(const QString& key) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocPlugin/StyleE.hpp b/Tests/QtAutogen/mocPlugin/StyleE.hpp deleted file mode 100644 index e7915a8..0000000 --- a/Tests/QtAutogen/mocPlugin/StyleE.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STYLEE_HPP -#define STYLEE_HPP - -#include "StyleCommon.hpp" -#include - -class StyleE : public QStylePlugin -{ - Q_OBJECT - // No Json file - Q_PLUGIN_METADATA(IID "org.styles.E") - A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg) -public: - QStyle* create(const QString& key); -}; - -#endif diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json deleted file mode 100644 index 129cac4..0000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json deleted file mode 100644 index 129cac4..0000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json deleted file mode 100644 index 119aaa4..0000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Boat", "Ship" ] } diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json deleted file mode 100644 index 732c547..0000000 --- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "Bike", "Car" ] } diff --git a/Tests/QtAutogen/mocPlugin/main.cpp b/Tests/QtAutogen/mocPlugin/main.cpp deleted file mode 100644 index 3ba2ddc..0000000 --- a/Tests/QtAutogen/mocPlugin/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "StyleA.hpp" - -int main(int argv, char** args) -{ - return 0; -} diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt deleted file mode 100644 index 7380bdd..0000000 --- a/Tests/QtAutogen/mocRerun/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -cmake_policy(SET CMP0071 NEW) -project(mocRerun CXX) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -# Generated source file -add_custom_command(OUTPUT main.cpp - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - ) - -add_executable(mocRerun - ${CMAKE_CURRENT_BINARY_DIR}/test1.h - ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - res1.qrc - ) -target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(mocRerun ${QT_CORE_TARGET}) -# Write target name to text file -add_custom_command(TARGET mocRerun POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$" > target1.txt) diff --git a/Tests/QtAutogen/mocRerun/input.txt b/Tests/QtAutogen/mocRerun/input.txt deleted file mode 100644 index da62762..0000000 --- a/Tests/QtAutogen/mocRerun/input.txt +++ /dev/null @@ -1 +0,0 @@ -Res1 input. diff --git a/Tests/QtAutogen/mocRerun/main.cpp.in b/Tests/QtAutogen/mocRerun/main.cpp.in deleted file mode 100644 index b37ff61..0000000 --- a/Tests/QtAutogen/mocRerun/main.cpp.in +++ /dev/null @@ -1,18 +0,0 @@ -#include "test1.h" - -class Test2 : public QObject -{ - Q_OBJECT -public slots: - void onTst1() {} -}; - -int main() -{ - Test1 test1; - Test2 test2; - - return 0; -} - -#include "main.moc" diff --git a/Tests/QtAutogen/mocRerun/res1.qrc b/Tests/QtAutogen/mocRerun/res1.qrc deleted file mode 100644 index fb804b5..0000000 --- a/Tests/QtAutogen/mocRerun/res1.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - input.txt - - diff --git a/Tests/QtAutogen/mocRerun/test1a.h.in b/Tests/QtAutogen/mocRerun/test1a.h.in deleted file mode 100644 index a335046..0000000 --- a/Tests/QtAutogen/mocRerun/test1a.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#include -class Test1 : public QObject -{ - Q_OBJECT -public slots: - void onTst1() {} - void onTst2() {} -}; diff --git a/Tests/QtAutogen/mocRerun/test1b.h.in b/Tests/QtAutogen/mocRerun/test1b.h.in deleted file mode 100644 index 6128eeb..0000000 --- a/Tests/QtAutogen/mocRerun/test1b.h.in +++ /dev/null @@ -1,7 +0,0 @@ -#include -class Test1 : public QObject -{ - Q_OBJECT -public slots: - void onTst1() {} -}; diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt deleted file mode 100644 index edc0ac3..0000000 --- a/Tests/QtAutogen/rccDepends/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -project(rccDepends CXX) - -set(CMAKE_AUTORCC ON) - -if (QT_TEST_VERSION STREQUAL 4) - find_package(Qt4 REQUIRED) - set(QT_CORE_TARGET Qt4::QtCore) -else() - if (NOT QT_TEST_VERSION STREQUAL 5) - message(SEND_ERROR "Invalid Qt version specified.") - endif() - - find_package(Qt5Core REQUIRED) - set(QT_CORE_TARGET Qt5::Core) -endif() - -configure_file(res/input1.txt.in res1/input.txt COPYONLY) -configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY) -configure_file(res/input2.txt.in res2/input.txt COPYONLY) -configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY) -# Dependency generated qrc file -add_custom_command(OUTPUT res2.qrc - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in - COMMAND ${CMAKE_COMMAND} -E sleep 2 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc - ) - -add_executable(rccDepends - main.cpp - ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc - ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc ) -target_link_libraries(rccDepends ${QT_CORE_TARGET}) -add_custom_command(TARGET rccDepends POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$" > target.txt) diff --git a/Tests/QtAutogen/rccDepends/main.cpp b/Tests/QtAutogen/rccDepends/main.cpp deleted file mode 100644 index 766b775..0000000 --- a/Tests/QtAutogen/rccDepends/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ - -int main() -{ - return 0; -} diff --git a/Tests/QtAutogen/rccDepends/res/input1.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in deleted file mode 100644 index da62762..0000000 --- a/Tests/QtAutogen/rccDepends/res/input1.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res1 input. diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in deleted file mode 100644 index 08e14b7..0000000 --- a/Tests/QtAutogen/rccDepends/res/input2.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res2 input. diff --git a/Tests/QtAutogen/rccDepends/res1a.qrc.in b/Tests/QtAutogen/rccDepends/res1a.qrc.in deleted file mode 100644 index d111ffb..0000000 --- a/Tests/QtAutogen/rccDepends/res1a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ - - - res1/input.txt - - diff --git a/Tests/QtAutogen/rccDepends/res1b.qrc.in b/Tests/QtAutogen/rccDepends/res1b.qrc.in deleted file mode 100644 index 4cb3f04..0000000 --- a/Tests/QtAutogen/rccDepends/res1b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ - - - res1/input.txt - res1/inputAdded.txt - - diff --git a/Tests/QtAutogen/rccDepends/res2a.qrc.in b/Tests/QtAutogen/rccDepends/res2a.qrc.in deleted file mode 100644 index 19f34ac..0000000 --- a/Tests/QtAutogen/rccDepends/res2a.qrc.in +++ /dev/null @@ -1,5 +0,0 @@ - - - res2/input.txt - - diff --git a/Tests/QtAutogen/rccDepends/res2b.qrc.in b/Tests/QtAutogen/rccDepends/res2b.qrc.in deleted file mode 100644 index 19e8ba1..0000000 --- a/Tests/QtAutogen/rccDepends/res2b.qrc.in +++ /dev/null @@ -1,6 +0,0 @@ - - - res2/input.txt - res2/inputAdded.txt - - diff --git a/Tests/QtAutogenRerun/CMakeLists.txt b/Tests/QtAutogenRerun/CMakeLists.txt new file mode 100644 index 0000000..088025f --- /dev/null +++ b/Tests/QtAutogenRerun/CMakeLists.txt @@ -0,0 +1,239 @@ +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) +project(QtAutogenRerun) + +# Tell find_package(Qt5) where to find Qt. +if(QT_QMAKE_EXECUTABLE) + get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) + get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH) + set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR}) +endif() + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + + # Include this directory before using the UseQt4 file. + add_subdirectory(defines_test) + + include(UseQt4) + + set(QT_QTCORE_TARGET Qt4::QtCore) + +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + find_package(Qt5Widgets REQUIRED) + + set(QT_QTCORE_TARGET Qt5::Core) + + include_directories(${Qt5Widgets_INCLUDE_DIRS}) + set(QT_LIBRARIES Qt5::Widgets) + + if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + endif() + +endif() + +# -- Test +# Dummy test to generate clean target +add_executable(dummy dummy.cpp) + +# -- Test +# When a file listed in a .qrc file changes the target must be rebuilt +set(timeformat "%Y%j%H%M%S") +set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends") +set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends") +configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) +configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) +try_compile(RCC_DEPENDS + "${RCC_DEPENDS_BIN}" + "${RCC_DEPENDS_SRC}" + rccDepends + CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output +) +if (NOT RCC_DEPENDS) + message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") +endif() +# Get name and timestamp of the output binary +file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList ENCODING UTF-8) +list(GET targetList 0 rccDependsBin) +file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}") +# Sleep, touch regular qrc input file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Second build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}") +if (NOT timeStep1 GREATER timeBegin) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!") +endif() +# Sleep, update regular qrc file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Third build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}") +if (NOT timeStep2 GREATER timeStep1) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!") +endif() +# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Fourth build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}") +if (NOT timeStep3 GREATER timeStep2) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!") +endif() +# Sleep, touch generated qrc input file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Fifth build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}") +if (NOT timeStep4 GREATER timeStep3) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!") +endif() +# Sleep, update generated qrc file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Sixth build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}") +if (NOT timeStep5 GREATER timeStep4) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!") +endif() +# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result) +if (result) + message(SEND_ERROR "Seventh build of rccDepends failed.") +endif() +file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}") +if (NOT timeStep6 GREATER timeStep5) + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!") +endif() + + +# -- Test +# Ensure a repeated build succeeds when a header containing a QObject changes +set(timeformat "%Y%j%H%M%S") +configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY) +try_compile(MOC_RERUN + "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" + "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun" + mocRerun + CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output +) +if (NOT MOC_RERUN) + message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}") +endif() +# Get name and timestamp of the output binary +file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List ENCODING UTF-8) +list(GET target1List 0 binFile) +file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") +# Change file content and rebuild +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY) +execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun" + RESULT_VARIABLE mocRerun_result + ) +if (mocRerun_result) + message(SEND_ERROR "Second build of mocRerun failed.") +endif() +# Compare timestamps +file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") +if (NOT timeStep1 GREATER timeBegin) + message(SEND_ERROR "File (${binFile}) should have changed in the first step!") +endif() + + +# -- Test +# Tests Q_PLUGIN_METADATA json file change detection +if (NOT QT_TEST_VERSION STREQUAL 4) + try_compile(MOC_PLUGIN + "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin" + "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin" + mocPlugin + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}" + OUTPUT_VARIABLE output + ) + if (NOT MOC_PLUGIN) + message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") + endif() + + set(timeformat "%Y%j%H%M%S") + set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin") + set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin") + find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) + find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) + find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) + find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) + + file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") + file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") + file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") + file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") + + # Ensure that the timestamp will change and change the json files + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) + configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") + configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") + + file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") + file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") + file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") + file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") + + if (plAAfter GREATER plABefore) + message(SEND_ERROR "file (${plAFile}) should not have changed!") + endif() + if (plBAfter GREATER plBBefore) + message(SEND_ERROR "file (${plBFile}) should not have changed!") + endif() + if (NOT plCAfter GREATER plCBefore) + message(SEND_ERROR "file (${plCFile}) should have changed!") + endif() + if (NOT plDAfter GREATER plDBefore) + message(SEND_ERROR "file (${plDFile}) should have changed!") + endif() + + # Test custom macro + file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") + file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) + configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") + configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") + file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") + file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") + if (NOT plCAfter GREATER plCBefore) + message(SEND_ERROR "file (${plCFile}) should have changed!") + endif() + if (NOT plDAfter GREATER plDBefore) + message(SEND_ERROR "file (${plDFile}) should have changed!") + endif() + +endif() diff --git a/Tests/QtAutogenRerun/defines_test/CMakeLists.txt b/Tests/QtAutogenRerun/defines_test/CMakeLists.txt new file mode 100644 index 0000000..9ee9a22 --- /dev/null +++ b/Tests/QtAutogenRerun/defines_test/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(defines_test defines_test.cpp) +set_target_properties(defines_test PROPERTIES AUTOMOC TRUE) +target_link_libraries(defines_test Qt4::QtGui) diff --git a/Tests/QtAutogenRerun/defines_test/defines_test.cpp b/Tests/QtAutogenRerun/defines_test/defines_test.cpp new file mode 100644 index 0000000..cf4e9cb --- /dev/null +++ b/Tests/QtAutogenRerun/defines_test/defines_test.cpp @@ -0,0 +1,38 @@ + +#include + +#ifdef QT_GUI_LIB +#include + +class SomeDocument : public QTextDocument +{ + Q_OBJECT + +Q_SIGNALS: + void someSig(); +}; +#endif + +#ifdef QT_CORE_LIB +class SomeObject : public QObject +{ + Q_OBJECT + +Q_SIGNALS: + void someSig(); +}; +#endif + +int main(int argc, char** argv) +{ +#ifdef QT_CORE_LIB + QMetaObject sosmo = SomeObject::staticMetaObject; +#endif +#ifdef QT_GUI_LIB + QMetaObject sdsmo = SomeDocument::staticMetaObject; +#endif + + return 0; +} + +#include "defines_test.moc" diff --git a/Tests/QtAutogenRerun/dummy.cpp b/Tests/QtAutogenRerun/dummy.cpp new file mode 100644 index 0000000..4837a76 --- /dev/null +++ b/Tests/QtAutogenRerun/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt b/Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt new file mode 100644 index 0000000..9b224fb --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.9) +project(mocPlugin CXX) + +set(CMAKE_AUTOMOC_DEPEND_FILTERS + "A_CUSTOM_MACRO" + "[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\"" + ) + +if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") +endif() +find_package(Qt5Widgets REQUIRED) + +if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) +endif() + +configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json) +configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json) +configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json) +configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json) + +# Enable automoc +set(CMAKE_AUTOMOC TRUE) + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles") +link_libraries(Qt5::Widgets) + +add_library(PlugA STATIC StyleA.cpp) +add_library(PlugB STATIC StyleB.cpp) +add_library(PlugC STATIC StyleC.cpp) +add_library(PlugD STATIC StyleD.cpp) +add_library(PlugE STATIC StyleE.cpp) diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleA.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleA.cpp new file mode 100644 index 0000000..b5e8753 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.cpp @@ -0,0 +1,6 @@ +#include "StyleA.hpp" + +QStyle* StyleA::create(const QString& key) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleA.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleA.hpp new file mode 100644 index 0000000..1b6154d --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEA_HPP +#define STYLEA_HPP + +#include "StyleCommon.hpp" +#include + +class StyleA : public QStylePlugin +{ + Q_OBJECT + // Json file in local directory + Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json") + A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleA.json b/Tests/QtAutogenRerun/mocPlugin/StyleA.json new file mode 100644 index 0000000..cc33953 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA.json @@ -0,0 +1 @@ +{ "Keys": [ "Rocket", "Starbuster" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json b/Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json new file mode 100644 index 0000000..cc33953 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleA_Custom.json @@ -0,0 +1 @@ +{ "Keys": [ "Rocket", "Starbuster" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleB.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleB.cpp new file mode 100644 index 0000000..17d4400 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleB.cpp @@ -0,0 +1,6 @@ +#include "StyleB.hpp" + +QStyle* StyleB::create(const QString& key) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleB.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleB.hpp new file mode 100644 index 0000000..163c9b2 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleB.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEB_HPP +#define STYLEB_HPP + +#include "StyleCommon.hpp" +#include + +class StyleB : public QStylePlugin +{ + Q_OBJECT + // Json file in local subdirectory + Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json") + A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleC.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleC.cpp new file mode 100644 index 0000000..37e7564 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleC.cpp @@ -0,0 +1,6 @@ +#include "StyleC.hpp" + +QStyle* StyleC::create(const QString& key) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleC.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleC.hpp new file mode 100644 index 0000000..52a887a --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleC.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEC_HPP +#define STYLEC_HPP + +#include "StyleCommon.hpp" +#include + +class StyleC : public QStylePlugin +{ + Q_OBJECT + // Json file in global root directory + Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json") + A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleCommon.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleCommon.hpp new file mode 100644 index 0000000..f1a7ec6 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleCommon.hpp @@ -0,0 +1,7 @@ +#ifndef STYLECOMMON_HPP +#define STYLECOMMON_HPP + +// Empty test macro definition +#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations) + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleD.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleD.cpp new file mode 100644 index 0000000..7e4b121 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleD.cpp @@ -0,0 +1,6 @@ +#include "StyleD.hpp" + +QStyle* StyleD::create(const QString& key) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleD.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleD.hpp new file mode 100644 index 0000000..df8a439 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleD.hpp @@ -0,0 +1,17 @@ +#ifndef STYLED_HPP +#define STYLED_HPP + +#include "StyleCommon.hpp" +#include + +class StyleD : public QStylePlugin +{ + Q_OBJECT + // Json file in global sub director + Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json") + A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleE.cpp b/Tests/QtAutogenRerun/mocPlugin/StyleE.cpp new file mode 100644 index 0000000..8fc9a7f --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleE.cpp @@ -0,0 +1,6 @@ +#include "StyleE.hpp" + +QStyle* StyleE::create(const QString& key) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp b/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp new file mode 100644 index 0000000..e7915a8 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/StyleE.hpp @@ -0,0 +1,17 @@ +#ifndef STYLEE_HPP +#define STYLEE_HPP + +#include "StyleCommon.hpp" +#include + +class StyleE : public QStylePlugin +{ + Q_OBJECT + // No Json file + Q_PLUGIN_METADATA(IID "org.styles.E") + A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg) +public: + QStyle* create(const QString& key); +}; + +#endif diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json new file mode 100644 index 0000000..129cac4 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB.json @@ -0,0 +1 @@ +{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json new file mode 100644 index 0000000..129cac4 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleB_Custom.json @@ -0,0 +1 @@ +{ "Keys": [ "Rocket", "StarbusterB" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json new file mode 100644 index 0000000..119aaa4 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleC.json @@ -0,0 +1 @@ +{ "Keys": [ "Boat", "Ship" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json new file mode 100644 index 0000000..732c547 --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleD.json @@ -0,0 +1 @@ +{ "Keys": [ "Bike", "Car" ] } diff --git a/Tests/QtAutogenRerun/mocPlugin/main.cpp b/Tests/QtAutogenRerun/mocPlugin/main.cpp new file mode 100644 index 0000000..3ba2ddc --- /dev/null +++ b/Tests/QtAutogenRerun/mocPlugin/main.cpp @@ -0,0 +1,6 @@ +#include "StyleA.hpp" + +int main(int argv, char** args) +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt new file mode 100644 index 0000000..7380bdd --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0071 NEW) +project(mocRerun CXX) + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + set(QT_CORE_TARGET Qt4::QtCore) +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + + find_package(Qt5Core REQUIRED) + set(QT_CORE_TARGET Qt5::Core) +endif() + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +# Generated source file +add_custom_command(OUTPUT main.cpp + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + ) + +add_executable(mocRerun + ${CMAKE_CURRENT_BINARY_DIR}/test1.h + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + res1.qrc + ) +target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(mocRerun ${QT_CORE_TARGET}) +# Write target name to text file +add_custom_command(TARGET mocRerun POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$" > target1.txt) diff --git a/Tests/QtAutogenRerun/mocRerun/input.txt b/Tests/QtAutogenRerun/mocRerun/input.txt new file mode 100644 index 0000000..da62762 --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/input.txt @@ -0,0 +1 @@ +Res1 input. diff --git a/Tests/QtAutogenRerun/mocRerun/main.cpp.in b/Tests/QtAutogenRerun/mocRerun/main.cpp.in new file mode 100644 index 0000000..b37ff61 --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/main.cpp.in @@ -0,0 +1,18 @@ +#include "test1.h" + +class Test2 : public QObject +{ + Q_OBJECT +public slots: + void onTst1() {} +}; + +int main() +{ + Test1 test1; + Test2 test2; + + return 0; +} + +#include "main.moc" diff --git a/Tests/QtAutogenRerun/mocRerun/res1.qrc b/Tests/QtAutogenRerun/mocRerun/res1.qrc new file mode 100644 index 0000000..fb804b5 --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/res1.qrc @@ -0,0 +1,5 @@ + + + input.txt + + diff --git a/Tests/QtAutogenRerun/mocRerun/test1a.h.in b/Tests/QtAutogenRerun/mocRerun/test1a.h.in new file mode 100644 index 0000000..a335046 --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/test1a.h.in @@ -0,0 +1,8 @@ +#include +class Test1 : public QObject +{ + Q_OBJECT +public slots: + void onTst1() {} + void onTst2() {} +}; diff --git a/Tests/QtAutogenRerun/mocRerun/test1b.h.in b/Tests/QtAutogenRerun/mocRerun/test1b.h.in new file mode 100644 index 0000000..6128eeb --- /dev/null +++ b/Tests/QtAutogenRerun/mocRerun/test1b.h.in @@ -0,0 +1,7 @@ +#include +class Test1 : public QObject +{ + Q_OBJECT +public slots: + void onTst1() {} +}; diff --git a/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt b/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt new file mode 100644 index 0000000..edc0ac3 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.9) +project(rccDepends CXX) + +set(CMAKE_AUTORCC ON) + +if (QT_TEST_VERSION STREQUAL 4) + find_package(Qt4 REQUIRED) + set(QT_CORE_TARGET Qt4::QtCore) +else() + if (NOT QT_TEST_VERSION STREQUAL 5) + message(SEND_ERROR "Invalid Qt version specified.") + endif() + + find_package(Qt5Core REQUIRED) + set(QT_CORE_TARGET Qt5::Core) +endif() + +configure_file(res/input1.txt.in res1/input.txt COPYONLY) +configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY) +configure_file(res/input2.txt.in res2/input.txt COPYONLY) +configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY) +# Dependency generated qrc file +add_custom_command(OUTPUT res2.qrc + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in + COMMAND ${CMAKE_COMMAND} -E sleep 2 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc + ) + +add_executable(rccDepends + main.cpp + ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc + ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc ) +target_link_libraries(rccDepends ${QT_CORE_TARGET}) +add_custom_command(TARGET rccDepends POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$" > target.txt) diff --git a/Tests/QtAutogenRerun/rccDepends/main.cpp b/Tests/QtAutogenRerun/rccDepends/main.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/QtAutogenRerun/rccDepends/res/input1.txt.in b/Tests/QtAutogenRerun/rccDepends/res/input1.txt.in new file mode 100644 index 0000000..da62762 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res/input1.txt.in @@ -0,0 +1 @@ +Res1 input. diff --git a/Tests/QtAutogenRerun/rccDepends/res/input2.txt.in b/Tests/QtAutogenRerun/rccDepends/res/input2.txt.in new file mode 100644 index 0000000..08e14b7 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res/input2.txt.in @@ -0,0 +1 @@ +Res2 input. diff --git a/Tests/QtAutogenRerun/rccDepends/res1a.qrc.in b/Tests/QtAutogenRerun/rccDepends/res1a.qrc.in new file mode 100644 index 0000000..d111ffb --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res1a.qrc.in @@ -0,0 +1,5 @@ + + + res1/input.txt + + diff --git a/Tests/QtAutogenRerun/rccDepends/res1b.qrc.in b/Tests/QtAutogenRerun/rccDepends/res1b.qrc.in new file mode 100644 index 0000000..4cb3f04 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res1b.qrc.in @@ -0,0 +1,6 @@ + + + res1/input.txt + res1/inputAdded.txt + + diff --git a/Tests/QtAutogenRerun/rccDepends/res2a.qrc.in b/Tests/QtAutogenRerun/rccDepends/res2a.qrc.in new file mode 100644 index 0000000..19f34ac --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res2a.qrc.in @@ -0,0 +1,5 @@ + + + res2/input.txt + + diff --git a/Tests/QtAutogenRerun/rccDepends/res2b.qrc.in b/Tests/QtAutogenRerun/rccDepends/res2b.qrc.in new file mode 100644 index 0000000..19e8ba1 --- /dev/null +++ b/Tests/QtAutogenRerun/rccDepends/res2b.qrc.in @@ -0,0 +1,6 @@ + + + res2/input.txt + res2/inputAdded.txt + + -- cgit v0.12