Bug 1698131 - Suppress websocket server errors in mochitests; r=jmaher

mod_pywebsocket3 inherits the stdout and stderr handles of its parent process
(the mochitest harness), so anything printed by the websocket server will appear
in the mochitest log. Most websocket server output is logged to a separate log
file, but exceptions are dumped to stderr.
test_worker_websocket2.html appropriately tests special unicode characters in
the reason code used when closing the websocket. On Windows, under python-3,
the special content of that reason code causes an exception in the mod_pywebsocket3
logging, which is reported to the mochitest log; the test still passes and the
websocket server continues to run correctly, but the exception is picked up by
the treeherder log parser as a "failure".
This patch suppresses the websocket server stderr so that any exception reported
by the websocket server will not affect test status directly.

Differential Revision: https://phabricator.services.mozilla.com/D108308
This commit is contained in:
Geoff Brown 2021-03-15 13:53:10 +00:00
Родитель d7f1d89a5e
Коммит 605df9dfee
1 изменённых файлов: 8 добавлений и 2 удалений

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

@ -618,8 +618,14 @@ class WebSocketServer(object):
]
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(sys.path)
# start the process
self._process = mozprocess.ProcessHandler(cmd, cwd=SCRIPT_DIR, env=env)
# Start the process. Ignore stderr so that exceptions from the server
# are not treated as failures when parsing the test log.
self._process = mozprocess.ProcessHandler(
cmd,
cwd=SCRIPT_DIR,
env=env,
processStderrLine=lambda _: None,
)
self._process.run()
pid = self._process.pid
self._log.info("runtests.py | Websocket server pid: %d" % pid)