on xenial help sign in
Changes to paths to use builddir/install for mocks on desktop.
commitf918aa2262292ce47f616950a1020e2b719915e8 authorChristopher Lee <chris.lee@canonical.com> dateMon 22 Jul 2013, 13:04 (13 years ago) parentadeee04
3 files changed+35−26
tests/autopilot/unity8/__init__.py+23−3 tests/autopilot/unity8/shell/__init__.py+7−12 tests/autopilot/unity8/shell/tests/__init__.py+5−11
tests/autopilot/unity8/__init__.py+23−3
@@ -36,21 +36,41 @@ def get_lib_path():
3636 "/usr/lib/",
3737 sysconfig.get_config_var('MULTIARCH'),
3838 "unity8"
39− )
39+ )
4040 else:
4141 binary_path = get_unity8_binary_path()
4242 lib_path = os.path.dirname(binary_path)
4343 return lib_path
4444
4545
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+
4666def get_unity8_binary_path():
4767 """Return the path to the unity8 binary."""
4868 binary_path = os.path.abspath(
4969 os.path.join(
5070 os.path.dirname(__file__),
51− "../../../builddir/unity8"
52− )
71+ "../../../builddir/install/bin/unity8"
5372 )
73+ )
5474 if not os.path.exists(binary_path):
5575 try:
5676 binary_path = subprocess.check_output(['which', 'unity8']).strip()
tests/autopilot/unity8/shell/__init__.py+7−12
@@ -23,7 +23,7 @@ from functools import wraps
2323import logging
2424import os.path
2525
26−from unity8 import get_lib_path, running_installed_tests
26+from unity8 import get_mocks_library_path
2727
2828
2929logger = logging.getLogger(__name__)
@@ -38,24 +38,19 @@ def with_lightdm_mock(mock_type):
3838 new_ld_library_path = _get_ld_library_path(mock_type)
3939 logger.info("New library path: %s", new_ld_library_path)
4040 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+ )
4245 return fn(*args, **kwargs)
4346 return wrapper
4447 return with_lightdm_mock_internal
4548
4649
4750def _get_ld_library_path(mock_type):
48− if running_installed_tests():
49− mock_path = "qml/mocks/LightDM/"
50− else:
51− mock_path = "../builddir/tests/mocks/LightDM/"
52− lib_path = get_lib_path()
51+ lib_path = get_mocks_library_path()
5352 new_ld_library_path = os.path.abspath(
54− os.path.join(
55− lib_path,
56− mock_path,
57− mock_type
58− )
53+ os.path.join(lib_path, "LightDM", mock_type)
5954 )
6055
6156 if not os.path.exists(new_ld_library_path):
tests/autopilot/unity8/shell/tests/__init__.py+5−11
@@ -28,7 +28,7 @@ import logging
2828import os.path
2929from testtools.matchers import Equals, NotEquals
3030
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
3232from unity8.shell.emulators import Unity8EmulatorBase
3333from unity8.shell.emulators.dash import Dash
3434from unity8.shell.emulators.main_window import MainWindow
@@ -132,11 +132,8 @@ class Unity8TestCase(AutopilotTestCase):
132132 binary_path
133133 )
134134
135− # we now have a path to the unity8 binary, and lib_path points to the
136− # directory where we need to patch some environment variables.
137− self._patch_environment(lib_path)
135+ self._setup_extra_mock_environment_patch()
138136
139− # launch the shell:
140137 app_proxy = self.launch_test_application(
141138 binary_path,
142139 *self.unity_geometry_args,
@@ -153,12 +150,9 @@ class Unity8TestCase(AutopilotTestCase):
153150 )
154151 return app_proxy
155152
156− def _patch_environment(self, lib_path):
157− """Patch environment variables for launching the unity8 shell."""
158− self.patch_environment(
159− "QML2_IMPORT_PATH",
160− os.path.join(lib_path, "qml/mocks")
161− )
153+ def _setup_extra_mock_environment_patch(self):
154+ mocks_library_path = get_mocks_library_path()
155+ self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)
162156
163157 def _set_proxy(self, proxy):
164158 """Keep a copy of the proxy object, so we can use it to get common parts