on xenial help sign in
Add autopkgtest definition and adapt unity8_ test macros
commit9c24f6da72f53ef16ee2b8d33c07ef4d4e260cce authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 30 Apr 2015, 22:44 (11 years ago) parent9c00c39
4 files changed+56−8
debian/control+1 debian/tests/control+4 debian/tests/qmluitests.sh+15 tests/CMakeLists.txt+36−8
debian/control+1
@@ -52,6 +52,7 @@ Build-Depends: cmake,
5252 qtdeclarative5-ubuntu-web-plugin,
5353 ttf-ubuntu-font-family,
5454Standards-Version: 3.9.4
55+XS-Testsuite: autopkgtest
5556Homepage: http://launchpad.net/unity
5657# If you aren't a member of ~unity-team but need to upload
5758# packaging changes, just go ahead. ~unity-team will notice
debian/tests/controlnew file+4
@@ -0,0 +1,4 @@
1+Tests: qmluitests.sh
2+Depends: @,
3+ @builddeps@,
4+ xvfb,
debian/tests/qmluitests.shnew file+15
@@ -0,0 +1,15 @@
1+#!/bin/sh
2+
3+SHELL_QML_PATH=$(pkg-config --variable=plugindir unity-shell-api)
4+
5+dh_auto_configure -- -DCMAKE_INSTALL_LOCALSTATEDIR="/var" \
6+ -DARTIFACTS_DIR=${ADT_ARTIFACTS} \
7+ -DUNITY_PLUGINPATH=${SHELL_QML_PATH} \
8+ -DUNITY_MOCKPATH=${SHELL_QML_PATH}/mocks \
9+ -DQUIET_LOGGER=ON
10+dh_auto_build -- -C tests/mocks 2>&1
11+dh_auto_build -- -C tests/plugins 2>&1
12+dh_auto_build -- -C tests/qmltests 2>&1
13+dh_auto_build -- -C tests/uqmlscene 2>&1
14+dh_auto_build -- -C tests/utils 2>&1
15+dh_auto_build -- xvfbuitests
tests/CMakeLists.txt+36−8
@@ -22,26 +22,54 @@ add_subdirectory(uqmlscene)
2222add_executable(qmlscene ALIAS uqmlscene)
2323import_executables(dbus-test-runner)
2424
25+set(UNITY_PLUGINPATH "" CACHE PATH "Path to pre-built unity8 plugin dir.")
26+set(UNITY_MOCKPATH "" CACHE PATH "Path to pre-built unity8 mock dir.")
27+
28+# Pre-built mocks have preference, pre-built plugins replace local build
29+set(import_paths "")
30+if(UNITY_MOCKPATH)
31+ list(APPEND import_paths ${UNITY_MOCKPATH})
32+endif()
33+list(APPEND import_paths
34+ ${CMAKE_BINARY_DIR}/tests/mocks
35+ ${CMAKE_BINARY_DIR}/tests/utils/modules
36+)
37+if(UNITY_PLUGINPATH)
38+ list(APPEND import_paths ${UNITY_PLUGINPATH})
39+else()
40+ list(APPEND import_paths ${CMAKE_BINARY_DIR}/plugins)
41+endif()
42+
43+# Pre-built mocks replace local build
44+if(UNITY_MOCKPATH)
45+ set(ld_paths
46+ ${UNITY_MOCKPATH}/libusermetrics
47+ ${UNITY_MOCKPATH}/LightDM/liblightdm
48+ )
49+else()
50+ set(ld_paths
51+ ${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
52+ ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm
53+ )
54+endif()
55+list(APPEND ld_paths ${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel)
56+string(REPLACE ";" ":" ld_library_path "${ld_paths}")
57+
2558# Base/default values
2659set(base_environment
2760 UNITY_TESTING=1
2861 LANGUAGE=C
2962 LC_ALL=C.UTF-8
63+ LD_LIBRARY_PATH=${ld_library_path}
3064)
3165
32−set(import_paths
33− ${CMAKE_BINARY_DIR}/tests/mocks
34− ${CMAKE_BINARY_DIR}/tests/utils/modules
35− ${CMAKE_BINARY_DIR}/plugins
36−)
37−
38−
3966# add a non-graphical unit test
4067# see QmlTest.cmake for additional options
4168function(add_unity8_unittest COMPONENT_NAME TARGET)
4269 cmake_parse_arguments(U8TEST "${QMLTEST_OPTIONS}" "${QMLTESTS_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
4370 add_executable_test(${COMPONENT_NAME} ${TARGET}
4471 ADD_TEST
72+ IMPORT_PATHS ${import_paths}
4573 TARGETS unittests
4674 ${ARGN}
4775 ENVIRONMENT ${base_environment}
@@ -54,6 +82,7 @@ endfunction()
5482function(add_unity8_uitest COMPONENT_NAME TARGET)
5583 cmake_parse_arguments(U8TEST "${QMLTEST_OPTIONS}" "${QMLTESTS_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
5684 add_executable_test(${COMPONENT_NAME} ${TARGET}
85+ IMPORT_PATHS ${import_paths}
5786 TARGETS uitests
5887 ${ARGN}
5988 ENVIRONMENT ${base_environment}
@@ -83,7 +112,6 @@ function(add_unity8_qmltest PATH COMPONENT_NAME)
83112 TARGETS uitests
84113 ${ARGN}
85114 ENVIRONMENT ${base_environment}
86− LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel
87115 ${U8TEST_ENVIRONMENT}
88116 )
89117endfunction()