on xenial help sign in
Wait for unity8 to terminate, kill if needed.
74fddf8Michał Sawicz
tests/autopilot/unity8/shell/tests/test_upstart.py+20−1
@@ -22,6 +22,7 @@
22import os
22import os
23import signal
23import signal
24import subprocess
24import subprocess
25+import time
25
26
26from testtools.matchers._basic import Equals
27from testtools.matchers._basic import Equals
27from autopilot.matchers import Eventually
28from autopilot.matchers import Eventually
@@ -49,7 +50,25 @@ class UpstartIntegrationTests(UnityTestCase):
49 def _launch_unity(self):
50 def _launch_unity(self):
50 self.patch_environment("QT_LOAD_TESTABILITY", "1")
51 self.patch_environment("QT_LOAD_TESTABILITY", "1")
51 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
52 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
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+
52− self.addCleanup(lambda: self.process.terminate())
71+ self.addCleanup(ensure_stopped)
53
72
54 def _set_proxy(self):
73 def _set_proxy(self):
55 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(
74 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(