Merge lp:~dandrader/unity/phablet_improve_cmake_add_qml_test into lp:unity/phablet

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: no longer in the source branch.
Merged at revision: 588
Proposed branch: lp:~dandrader/unity/phablet_improve_cmake_add_qml_test
Merge into: lp:unity/phablet
Diff against target: 98 lines (+28/-22)
4 files modified
tests/CMakeLists.txt (+23/-17)
tests/qmluitests/Components/CMakeLists.txt (+1/-1)
tests/qmluitests/Hud/CMakeLists.txt (+1/-1)
tests/qmluitests/Panel/CMakeLists.txt (+3/-3)
To merge this branch: bzr merge lp:~dandrader/unity/phablet_improve_cmake_add_qml_test
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+158386@code.launchpad.net

Commit message

Improve add_qml_test() CMake function

- Improve its documentation
- Add support for multiple QML import paths
- Refactor implementation of PROPERTIES argument.
  Turn it into a multi-valued keyword.

Description of the change

Improve add_qml_test() CMake function

- Improve its documentation
- Add support for multiple QML import paths
- Refactor implementation of PROPERTIES argument. Turn it into a multi-valued keyword.

Needed by lp:~dandrader/unity/phablet_remove_fakes_from_qml

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

this failure should go away after lp:~saviq/unity/phablet.add-python3-dep gets merged

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

16 +# IMPORT_PATHS will pass that path to qmltestrunner as "-import" arguments
"those paths"

25 + set(multi_value_keywords "IMPORT_PATHS" "TARGETS" "PROPERTIES")
no need for the quotes

28 + cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
rogue space

47 + list(APPEND qmltestrunner_imports "-import")
48 + list(APPEND qmltestrunner_imports ${IMPORT_PATH})
I would probably just go and set(var "${var} -import ${IMPORT_PATH}") here, but that's good, too

Just some nitpicks, otherwise good!

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> 16 +# IMPORT_PATHS will pass that path to qmltestrunner as "-import"
> arguments
> "those paths"

will fix

>
> 25 + set(multi_value_keywords "IMPORT_PATHS" "TARGETS" "PROPERTIES")
> no need for the quotes

will change

>
> 28 + cmake_parse_arguments(qmltest "${options}" ""
> "${multi_value_keywords}" ${ARGN})
> rogue space

This is not a rogue space. This is the argument for single-valued keywords, which we have none now.

>
> 47 + list(APPEND qmltestrunner_imports "-import")
> 48 + list(APPEND qmltestrunner_imports ${IMPORT_PATH})
> I would probably just go and set(var "${var} -import ${IMPORT_PATH}") here,
> but that's good, too

Appending has better performance. But I could probably merge the two in a single append command.

Revision history for this message
Michał Sawicz (saviq) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2013-04-11 14:19:06 +0000
+++ tests/CMakeLists.txt 2013-04-12 13:31:24 +0000
@@ -1,9 +1,13 @@
1# add_qml_test(component_name [NO_ADD_TEST] [NO_TARGETS] [TARGETS target1 target2] [IMPORT_PATH import_path] [PROPERTIES ...])1# add_qml_test(component_name [NO_ADD_TEST] [NO_TARGETS]
2# [TARGETS target1 [target2 [...]]]
3# [IMPORT_PATHS import_path1 [import_path2 [...]]
4# [PROPERTIES prop1 value1 [prop2 value2 [...]]])
5#
2# NO_ADD_TEST will prevent adding the test to the "make test" target6# NO_ADD_TEST will prevent adding the test to the "make test" target
3# NO_TARGETS will prevent adding the test to any targets7# NO_TARGETS will prevent adding the test to any targets
4# TARGETS lists the targets the test should be added to8# TARGETS lists the targets the test should be added to
5# IMPORT_PATH will pass that path to qmltestrunner9# IMPORT_PATHS will pass those paths to qmltestrunner as "-import" arguments
6# PROPERTIES will be set on the target and test target10# PROPERTIES will be set on the target and test target. See CMake's set_target_properties()
7#11#
8# To change/set a default value for the whole test suite, prior to calling add_qml_test, set:12# To change/set a default value for the whole test suite, prior to calling add_qml_test, set:
9# qmltest_DEFAULT_NO_ADD_TEST (default: FALSE)13# qmltest_DEFAULT_NO_ADD_TEST (default: FALSE)
@@ -18,27 +22,29 @@
1822
19macro(add_qml_test COMPONENT_NAME)23macro(add_qml_test COMPONENT_NAME)
20 set(options NO_ADD_TEST NO_TARGETS)24 set(options NO_ADD_TEST NO_TARGETS)
25 set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES)
2126
22 cmake_parse_arguments(qmltest "${options}" "IMPORT_PATH" "TARGETS" ${ARGN})27 cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
2328
24 set(qmltest_TARGET test${COMPONENT_NAME})29 set(qmltest_TARGET test${COMPONENT_NAME})
25 set(qmltest_FILE tst_${COMPONENT_NAME})30 set(qmltest_FILE tst_${COMPONENT_NAME})
2631
27 if("${qmltest_IMPORT_PATH}" STREQUAL "")32 set(qmltestrunner_imports "")
28 add_custom_target(${qmltest_TARGET}33 if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
29 ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml34 foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
30 -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml35 list(APPEND qmltestrunner_imports "-import")
31 -o -,txt)36 list(APPEND qmltestrunner_imports ${IMPORT_PATH})
32 else()37 endforeach(IMPORT_PATH)
33 add_custom_target(${qmltest_TARGET}
34 ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
35 -import ${qmltest_IMPORT_PATH}
36 -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
37 -o -,txt)
38 endif()38 endif()
3939
40 if(NOT "${qmltest_UNPARSED_ARGUMENTS}" STREQUAL "")40 add_custom_target(${qmltest_TARGET}
41 set_target_properties(${qmltest_TARGET} ${qmltest_PROPERTIES})41 ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
42 ${qmltestrunner_imports}
43 -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
44 -o -,txt)
45
46 if(NOT "${qmltest_PROPERTIES}" STREQUAL "")
47 set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
42 elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")48 elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
43 set_target_properties(${qmltest_TARGET} ${qmltest_DEFAULT_PROPERTIES})49 set_target_properties(${qmltest_TARGET} ${qmltest_DEFAULT_PROPERTIES})
44 endif()50 endif()
4551
=== modified file 'tests/qmluitests/Components/CMakeLists.txt'
--- tests/qmluitests/Components/CMakeLists.txt 2013-04-09 21:36:17 +0000
+++ tests/qmluitests/Components/CMakeLists.txt 2013-04-12 13:31:24 +0000
@@ -1,5 +1,5 @@
1add_qml_test(DraggingArea)1add_qml_test(DraggingArea)
2add_qml_test(FilterGrid IMPORT_PATH ${CMAKE_BINARY_DIR}/plugins)2add_qml_test(FilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
3add_qml_test(ResponsiveFlowView)3add_qml_test(ResponsiveFlowView)
4add_qml_test(ResponsiveGridView)4add_qml_test(ResponsiveGridView)
5add_qml_test(Revealer)5add_qml_test(Revealer)
66
=== modified file 'tests/qmluitests/Hud/CMakeLists.txt'
--- tests/qmluitests/Hud/CMakeLists.txt 2013-04-09 09:04:49 +0000
+++ tests/qmluitests/Hud/CMakeLists.txt 2013-04-12 13:31:24 +0000
@@ -1,3 +1,3 @@
1add_subdirectory(qml)1add_subdirectory(qml)
22
3add_qml_test(Hud IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)3add_qml_test(Hud IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
44
=== modified file 'tests/qmluitests/Panel/CMakeLists.txt'
--- tests/qmluitests/Panel/CMakeLists.txt 2013-04-12 08:37:35 +0000
+++ tests/qmluitests/Panel/CMakeLists.txt 2013-04-12 13:31:24 +0000
@@ -1,6 +1,6 @@
1add_subdirectory(qml)1add_subdirectory(qml)
22
3add_qml_test(IndicatorRow IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)3add_qml_test(IndicatorRow IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
4add_qml_test(Indicators IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)4add_qml_test(Indicators IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
5add_qml_test(Panel IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)5add_qml_test(Panel IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
6add_qml_test(SearchIndicator)6add_qml_test(SearchIndicator)

Subscribers

People subscribed via source and target branches