on xenial help sign in
Changes to paths to use builddir/install for mocks on desktop.
f918aa2Christopher Lee
tests/autopilot/unity8/__init__.py+23−3
@@ -36,21 +36,41 @@ def get_lib_path():
36 "/usr/lib/",
36 "/usr/lib/",
37 sysconfig.get_config_var('MULTIARCH'),
37 sysconfig.get_config_var('MULTIARCH'),
38 "unity8"
38 "unity8"
39− )
39+ )
40 else:
40 else:
41 binary_path = get_unity8_binary_path()
41 binary_path = get_unity8_binary_path()
42 lib_path = os.path.dirname(binary_path)
42 lib_path = os.path.dirname(binary_path)
43 return lib_path
43 return lib_path
44
44
45
45
46+def get_mocks_library_path():
47+ if running_installed_tests():
48+ mock_path = "qml/mocks/"
49+ else:
50+ mock_path = "../lib/x86_64-linux-gnu/unity8/qml/mocks/"
51+ lib_path = get_lib_path()
52+ ld_library_path = os.path.abspath(
53+ os.path.join(
54+ lib_path,
55+ mock_path,
56+ )
57+ )
58+
59+ if not os.path.exists(ld_library_path):
60+ raise RuntimeError(
61+ "Expected library path does not exists: %s." % (ld_library_path)
62+ )
63+ return ld_library_path
64+
65+
46def get_unity8_binary_path():
66def get_unity8_binary_path():
47 """Return the path to the unity8 binary."""
67 """Return the path to the unity8 binary."""
48 binary_path = os.path.abspath(
68 binary_path = os.path.abspath(
49 os.path.join(
69 os.path.join(
50 os.path.dirname(__file__),
70 os.path.dirname(__file__),
51− "../../../builddir/unity8"
71+ "../../../builddir/install/bin/unity8"
52− )
53 )
72 )
73+ )
54 if not os.path.exists(binary_path):
74 if not os.path.exists(binary_path):
55 try:
75 try:
56 binary_path = subprocess.check_output(['which', 'unity8']).strip()
76 binary_path = subprocess.check_output(['which', 'unity8']).strip()
tests/autopilot/unity8/shell/__init__.py+7−12
@@ -23,7 +23,7 @@ from functools import wraps
23import logging
23import logging
24import os.path
24import os.path
25
25
26−from unity8 import get_lib_path, running_installed_tests
26+from unity8 import get_mocks_library_path
27
27
28
28
29logger = logging.getLogger(__name__)
29logger = logging.getLogger(__name__)
@@ -38,24 +38,19 @@ def with_lightdm_mock(mock_type):
38 new_ld_library_path = _get_ld_library_path(mock_type)
38 new_ld_library_path = _get_ld_library_path(mock_type)
39 logger.info("New library path: %s", new_ld_library_path)
39 logger.info("New library path: %s", new_ld_library_path)
40 tests_self = args[0]
40 tests_self = args[0]
41− tests_self.patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
41+ tests_self.patch_environment(
42+ 'LD_LIBRARY_PATH',
43+ new_ld_library_path
44+ )
42 return fn(*args, **kwargs)
45 return fn(*args, **kwargs)
43 return wrapper
46 return wrapper
44 return with_lightdm_mock_internal
47 return with_lightdm_mock_internal
45
48
46
49
47def _get_ld_library_path(mock_type):
50def _get_ld_library_path(mock_type):
48− if running_installed_tests():
51+ lib_path = get_mocks_library_path()
49− mock_path = "qml/mocks/LightDM/"
50− else:
51− mock_path = "../builddir/tests/mocks/LightDM/"
52− lib_path = get_lib_path()
53 new_ld_library_path = os.path.abspath(
52 new_ld_library_path = os.path.abspath(
54− os.path.join(
53+ os.path.join(lib_path, "LightDM", mock_type)
55− lib_path,
56− mock_path,
57− mock_type
58− )
59 )
54 )
60
55
61 if not os.path.exists(new_ld_library_path):
56 if not os.path.exists(new_ld_library_path):
tests/autopilot/unity8/shell/tests/__init__.py+5−11
@@ -28,7 +28,7 @@ import logging
28import os.path
28import os.path
29from testtools.matchers import Equals, NotEquals
29from testtools.matchers import Equals, NotEquals
30
30
31−from unity8 import get_lib_path, get_unity8_binary_path
31+from unity8 import get_lib_path, get_unity8_binary_path, get_mocks_library_path
32from unity8.shell.emulators import Unity8EmulatorBase
32from unity8.shell.emulators import Unity8EmulatorBase
33from unity8.shell.emulators.dash import Dash
33from unity8.shell.emulators.dash import Dash
34from unity8.shell.emulators.main_window import MainWindow
34from unity8.shell.emulators.main_window import MainWindow
@@ -132,11 +132,8 @@ class Unity8TestCase(AutopilotTestCase):
132 binary_path
132 binary_path
133 )
133 )
134
134
135− # we now have a path to the unity8 binary, and lib_path points to the
135+ self._setup_extra_mock_environment_patch()
136− # directory where we need to patch some environment variables.
137− self._patch_environment(lib_path)
138
136
139− # launch the shell:
140 app_proxy = self.launch_test_application(
137 app_proxy = self.launch_test_application(
141 binary_path,
138 binary_path,
142 *self.unity_geometry_args,
139 *self.unity_geometry_args,
@@ -153,12 +150,9 @@ class Unity8TestCase(AutopilotTestCase):
153 )
150 )
154 return app_proxy
151 return app_proxy
155
152
156− def _patch_environment(self, lib_path):
153+ def _setup_extra_mock_environment_patch(self):
157− """Patch environment variables for launching the unity8 shell."""
154+ mocks_library_path = get_mocks_library_path()
158− self.patch_environment(
155+ self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)
159− "QML2_IMPORT_PATH",
160− os.path.join(lib_path, "qml/mocks")
161− )
162
156
163 def _set_proxy(self, proxy):
157 def _set_proxy(self, proxy):
164 """Keep a copy of the proxy object, so we can use it to get common parts
158 """Keep a copy of the proxy object, so we can use it to get common parts