on xenial help sign in
Wait for unity8 to terminate, kill if needed.
commit74fddf848952276b76204c5ba13afb713cf52ea1 authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 25 Nov 2013, 12:16 (13 years ago) parent79a23b2
1 file changed+20−1
tests/autopilot/unity8/shell/tests/test_upstart.py+20−1
tests/autopilot/unity8/shell/tests/test_upstart.py+20−1
@@ -22,6 +22,7 @@
2222import os
2323import signal
2424import subprocess
25+import time
2526
2627from testtools.matchers._basic import Equals
2728from autopilot.matchers import Eventually
@@ -49,7 +50,25 @@ class UpstartIntegrationTests(UnityTestCase):
4950 def _launch_unity(self):
5051 self.patch_environment("QT_LOAD_TESTABILITY", "1")
5152 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
52− self.addCleanup(lambda: self.process.terminate())
53+ def ensure_stopped():
54+ self.process.terminate()
55+ for i in xrange(10):
56+ try:
57+ self._get_status()
58+ except OSError:
59+ break
60+ else:
61+ time.sleep(1)
62+ try:
63+ self._get_status()
64+ except OSError:
65+ pass
66+ else:
67+ self.process.kill()
68+
69+ self.process.wait()
70+
71+ self.addCleanup(ensure_stopped)
5372
5473 def _set_proxy(self):
5574 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(