diff options
author | Brad King <brad.king@kitware.com> | 2017-03-24 12:32:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-03-24 12:32:24 (GMT) |
commit | 0f4420e0a80993ccd6ce7d51eeb96e904b8bd9f8 (patch) | |
tree | 5d39dbda3bb2a77ae815bd126f2426306bd894a4 /Tests | |
parent | 8b25d8e23c1415a99c0cd270f6fe8c4b26749870 (diff) | |
parent | 35e8a6de86790c10a5157bbb90c730b47bc552fa (diff) | |
download | CMake-0f4420e0a80993ccd6ce7d51eeb96e904b8bd9f8.zip CMake-0f4420e0a80993ccd6ce7d51eeb96e904b8bd9f8.tar.gz CMake-0f4420e0a80993ccd6ce7d51eeb96e904b8bd9f8.tar.bz2 |
Merge topic 'autogen_rcc_test'
35e8a6de Autogen: Tests: More rigorous rcc rebuild tests
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !618
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/CMakeLists.txt | 102 | ||||
-rw-r--r-- | Tests/QtAutogen/mocRerun/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/QtAutogen/rccDepends/CMakeLists.txt | 19 | ||||
-rw-r--r-- | Tests/QtAutogen/rccDepends/res1a.qrc.in (renamed from Tests/QtAutogen/rccDepends/res1.qrc.in) | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/rccDepends/res1b.qrc.in | 6 | ||||
-rw-r--r-- | Tests/QtAutogen/rccDepends/res2a.qrc.in (renamed from Tests/QtAutogen/rccDepends/res2.qrc.in) | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/rccDepends/res2b.qrc.in | 6 |
7 files changed, 93 insertions, 47 deletions
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 86af746..101b396 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -82,9 +82,14 @@ 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 - "${CMAKE_CURRENT_BINARY_DIR}/rccDepends" - "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends" + "${RCC_DEPENDS_BIN}" + "${RCC_DEPENDS_SRC}" rccDepends CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}" @@ -94,47 +99,82 @@ try_compile(RCC_DEPENDS 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 "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/target1.txt" target1List) -list(GET target1List 0 binFile) -set(timeformat "%Y%j%H%M%S") -file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") - -# Touch first qrc input file and rebuild +file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList) +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 "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res1/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends" - RESULT_VARIABLE rccDepends_result -) -if (rccDepends_result) +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() -# Compare timestamps -file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") +file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}") if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "File (${binFile}) should have changed in the first step!") + message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!") endif() - -# Touch second qrc input file and rebuild +# Sleep, update regular qrc 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 "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res2/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends" - RESULT_VARIABLE rccDepends_result -) -if (rccDepends_result) +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() -# Compare timestamps -file(TIMESTAMP "${binFile}" timeStep2 "${timeformat}") +file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}") if (NOT timeStep2 GREATER timeStep1) - message(SEND_ERROR "File (${binFile}) should have changed in the second step!") + 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" @@ -147,13 +187,10 @@ try_compile(MOC_RERUN 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) list(GET target1List 0 binFile) -set(timeformat "%Y%j%H%M%S") 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) @@ -164,7 +201,6 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --build . if (mocRerun_result) message(SEND_ERROR "Second build of mocRerun failed.") endif() - # Compare timestamps file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") if (NOT timeStep1 GREATER timeBegin) diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt index 6689f50..69ea8d7 100644 --- a/Tests/QtAutogen/mocRerun/CMakeLists.txt +++ b/Tests/QtAutogen/mocRerun/CMakeLists.txt @@ -16,10 +16,9 @@ endif() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -configure_file(test1a.h.in test1.h COPYONLY) # Generated source file add_custom_command(OUTPUT main.cpp - COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp ) diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt index de98573..878ae5d 100644 --- a/Tests/QtAutogen/rccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt @@ -15,22 +15,21 @@ else() set(QT_CORE_TARGET Qt5::Core) endif() -configure_file(res/input1.txt.in res1/input.txt @ONLY) -configure_file(res/input2.txt.in res2/input.txt @ONLY) -# Configure time generated qrc file -configure_file(res1.qrc.in res1.qrc @ONLY) +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 - COMMAND ${CMAKE_COMMAND} -E sleep 3 - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/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 -) + ${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_FILE:rccDepends>" > target1.txt) + ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt) diff --git a/Tests/QtAutogen/rccDepends/res1.qrc.in b/Tests/QtAutogen/rccDepends/res1a.qrc.in index 2a5417b..d111ffb 100644 --- a/Tests/QtAutogen/rccDepends/res1.qrc.in +++ b/Tests/QtAutogen/rccDepends/res1a.qrc.in @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/Texts1"> <file>res1/input.txt</file> </qresource> </RCC> diff --git a/Tests/QtAutogen/rccDepends/res1b.qrc.in b/Tests/QtAutogen/rccDepends/res1b.qrc.in new file mode 100644 index 0000000..4cb3f04 --- /dev/null +++ b/Tests/QtAutogen/rccDepends/res1b.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/Texts1"> + <file>res1/input.txt</file> + <file alias="Added">res1/inputAdded.txt</file> + </qresource> +</RCC> diff --git a/Tests/QtAutogen/rccDepends/res2.qrc.in b/Tests/QtAutogen/rccDepends/res2a.qrc.in index 18b916a..19f34ac 100644 --- a/Tests/QtAutogen/rccDepends/res2.qrc.in +++ b/Tests/QtAutogen/rccDepends/res2a.qrc.in @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/Texts2"> <file>res2/input.txt</file> </qresource> </RCC> diff --git a/Tests/QtAutogen/rccDepends/res2b.qrc.in b/Tests/QtAutogen/rccDepends/res2b.qrc.in new file mode 100644 index 0000000..19e8ba1 --- /dev/null +++ b/Tests/QtAutogen/rccDepends/res2b.qrc.in @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/Texts2"> + <file>res2/input.txt</file> + <file alias="Added">res2/inputAdded.txt</file> + </qresource> +</RCC> |