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
1=== modified file 'tests/CMakeLists.txt'
2--- tests/CMakeLists.txt 2013-04-11 14:19:06 +0000
3+++ tests/CMakeLists.txt 2013-04-12 13:31:24 +0000
4@@ -1,9 +1,13 @@
5-# add_qml_test(component_name [NO_ADD_TEST] [NO_TARGETS] [TARGETS target1 target2] [IMPORT_PATH import_path] [PROPERTIES ...])
6+# add_qml_test(component_name [NO_ADD_TEST] [NO_TARGETS]
7+# [TARGETS target1 [target2 [...]]]
8+# [IMPORT_PATHS import_path1 [import_path2 [...]]
9+# [PROPERTIES prop1 value1 [prop2 value2 [...]]])
10+#
11 # NO_ADD_TEST will prevent adding the test to the "make test" target
12 # NO_TARGETS will prevent adding the test to any targets
13 # TARGETS lists the targets the test should be added to
14-# IMPORT_PATH will pass that path to qmltestrunner
15-# PROPERTIES will be set on the target and test target
16+# IMPORT_PATHS will pass those paths to qmltestrunner as "-import" arguments
17+# PROPERTIES will be set on the target and test target. See CMake's set_target_properties()
18 #
19 # To change/set a default value for the whole test suite, prior to calling add_qml_test, set:
20 # qmltest_DEFAULT_NO_ADD_TEST (default: FALSE)
21@@ -18,27 +22,29 @@
22
23 macro(add_qml_test COMPONENT_NAME)
24 set(options NO_ADD_TEST NO_TARGETS)
25+ set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES)
26
27- cmake_parse_arguments(qmltest "${options}" "IMPORT_PATH" "TARGETS" ${ARGN})
28+ cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
29
30 set(qmltest_TARGET test${COMPONENT_NAME})
31 set(qmltest_FILE tst_${COMPONENT_NAME})
32
33- if("${qmltest_IMPORT_PATH}" STREQUAL "")
34- add_custom_target(${qmltest_TARGET}
35- ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
36- -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
37- -o -,txt)
38- else()
39- add_custom_target(${qmltest_TARGET}
40- ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
41- -import ${qmltest_IMPORT_PATH}
42- -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
43- -o -,txt)
44+ set(qmltestrunner_imports "")
45+ if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
46+ foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
47+ list(APPEND qmltestrunner_imports "-import")
48+ list(APPEND qmltestrunner_imports ${IMPORT_PATH})
49+ endforeach(IMPORT_PATH)
50 endif()
51
52- if(NOT "${qmltest_UNPARSED_ARGUMENTS}" STREQUAL "")
53- set_target_properties(${qmltest_TARGET} ${qmltest_PROPERTIES})
54+ add_custom_target(${qmltest_TARGET}
55+ ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
56+ ${qmltestrunner_imports}
57+ -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
58+ -o -,txt)
59+
60+ if(NOT "${qmltest_PROPERTIES}" STREQUAL "")
61+ set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
62 elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
63 set_target_properties(${qmltest_TARGET} ${qmltest_DEFAULT_PROPERTIES})
64 endif()
65
66=== modified file 'tests/qmluitests/Components/CMakeLists.txt'
67--- tests/qmluitests/Components/CMakeLists.txt 2013-04-09 21:36:17 +0000
68+++ tests/qmluitests/Components/CMakeLists.txt 2013-04-12 13:31:24 +0000
69@@ -1,5 +1,5 @@
70 add_qml_test(DraggingArea)
71-add_qml_test(FilterGrid IMPORT_PATH ${CMAKE_BINARY_DIR}/plugins)
72+add_qml_test(FilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
73 add_qml_test(ResponsiveFlowView)
74 add_qml_test(ResponsiveGridView)
75 add_qml_test(Revealer)
76
77=== modified file 'tests/qmluitests/Hud/CMakeLists.txt'
78--- tests/qmluitests/Hud/CMakeLists.txt 2013-04-09 09:04:49 +0000
79+++ tests/qmluitests/Hud/CMakeLists.txt 2013-04-12 13:31:24 +0000
80@@ -1,3 +1,3 @@
81 add_subdirectory(qml)
82
83-add_qml_test(Hud IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)
84+add_qml_test(Hud IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
85
86=== modified file 'tests/qmluitests/Panel/CMakeLists.txt'
87--- tests/qmluitests/Panel/CMakeLists.txt 2013-04-12 08:37:35 +0000
88+++ tests/qmluitests/Panel/CMakeLists.txt 2013-04-12 13:31:24 +0000
89@@ -1,6 +1,6 @@
90 add_subdirectory(qml)
91
92-add_qml_test(IndicatorRow IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)
93-add_qml_test(Indicators IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)
94-add_qml_test(Panel IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR}/qml)
95+add_qml_test(IndicatorRow IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
96+add_qml_test(Indicators IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
97+add_qml_test(Panel IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/qml)
98 add_qml_test(SearchIndicator)

Subscribers

People subscribed via source and target branches