Bug 1772329 - Force kill node process and subprocesses in xpcshell tests at the end of the test r=jmaher,necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D189212
This commit is contained in:
Valentin Gosu 2023-09-28 09:03:59 +00:00
Родитель 85dbd41802
Коммит 10e8f63703
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -85,3 +85,11 @@ add_task(async function test_execute() {
)
);
});
add_task(async function killOnEnd() {
let id = await NodeServer.fork();
// Make the forked subprocess hang forever.
NodeServer.execute(id, "while (true) {}").catch(e => {});
await new Promise(resolve => do_timeout(10, resolve));
// Should get killed at the end of the test by the harness.
});

Просмотреть файл

@ -1434,6 +1434,9 @@ class XPCShellTests(object):
self.log.info("Node %s server shutting down ..." % name)
if proc.poll() is not None:
self.log.info("Node server %s already dead %s" % (name, proc.poll()))
elif sys.platform != "win32":
# Kill process and all its spawned children.
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
else:
proc.terminate()