Commit a29fbe95 authored by Sam Thursfield's avatar Sam Thursfield

functional-tests: Kill all subprocesses if one dies

This fixes an issue where `meson test` would hang until the test timed
out, instead of exiting immediately if one subprocess failed.
parent 6be9815c
......@@ -20,6 +20,7 @@
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
import atexit
import os
import sys
import subprocess
......@@ -39,6 +40,16 @@ def log (message):
if options.is_verbose ():
print (message)
_process_list = []
def _cleanup_processes():
for process in _process_list:
log("helpers._cleanup_processes: stopping %s" % process)
process.stop()
atexit.register(_cleanup_processes)
class Helper:
"""
Abstract helper for Tracker processes. Launches the process manually
......@@ -67,6 +78,9 @@ class Helper:
self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
def _start_process (self):
global _process_list
_process_list.append(self)
path = self.PROCESS_PATH
flags = getattr (self,
"FLAGS",
......@@ -154,6 +168,8 @@ class Helper:
self.abort_if_process_exits_with_status_0 = False
def stop (self):
global _process_list
if self.process is None:
# Seems that it didn't even start...
return
......@@ -180,8 +196,12 @@ class Helper:
Gio.bus_unwatch_name(self._bus_name_watch_id)
self.process = None
_process_list.remove(self)
def kill (self):
global _process_list
if options.is_manual_start():
log ("kill(): ignoring, because process was started manually.")
return
......@@ -193,6 +213,7 @@ class Helper:
Gio.bus_unwatch_name(self._bus_name_watch_id)
self.process = None
_process_list.remove(self)
log ("[%s] killed." % self.PROCESS_NAME)
......
......@@ -72,7 +72,10 @@ class CommonTrackerMinerTest (ut.TestCase):
}
}
self.system.tracker_miner_fs_testing_start (config)
try:
self.system.tracker_miner_fs_testing_start (config)
except RuntimeError as e:
self.fail(e)
self.tracker = self.system.store
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment