mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Bug 654354 - Don't output python backtraces when a mochitest is killed via ctrl-c. r=ted
--HG-- rename : testing/mochitest/pywebsocket_ignore_sigint.py => testing/mochitest/pywebsocket_wrapper.py
This commit is contained in:
parent
8148576e7f
commit
c0ec59bd30
@ -101,7 +101,7 @@ _SERV_FILES = \
|
||||
$(topsrcdir)/build/pgo/server-locations.txt \
|
||||
$(topsrcdir)/netwerk/test/httpserver/httpd.js \
|
||||
mozprefs.js \
|
||||
pywebsocket_ignore_sigint.py \
|
||||
pywebsocket_wrapper.py \
|
||||
$(NULL)
|
||||
|
||||
_PYWEBSOCKET_FILES = \
|
||||
|
@ -49,5 +49,13 @@ if __name__ == '__main__':
|
||||
sys.path = ['pywebsocket'] + sys.path
|
||||
import standalone
|
||||
|
||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
# If we received --interactive as the first argument, ignore SIGINT so
|
||||
# pywebsocket doesn't die on a ctrl+c meant for the debugger. Otherwise,
|
||||
# die immediately on SIGINT so we don't print a messy backtrace.
|
||||
if len(sys.argv) >= 2 and sys.argv[1] == '--interactive':
|
||||
del sys.argv[1]
|
||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
else:
|
||||
signal.signal(signal.SIGINT, lambda signum, frame: sys.exit(1))
|
||||
|
||||
standalone._main()
|
@ -375,15 +375,21 @@ class WebSocketServer(object):
|
||||
self.debuggerInfo = debuggerInfo
|
||||
|
||||
def start(self):
|
||||
# If we're running tests under an interactive debugger, tell the server to
|
||||
# ignore SIGINT so it doesn't capture a ctrl+c meant for the debugger.
|
||||
if self.debuggerInfo and self.debuggerInfo['interactive']:
|
||||
scriptPath = 'pywebsocket_ignore_sigint.py'
|
||||
else:
|
||||
scriptPath = 'pywebsocket/standalone.py'
|
||||
|
||||
# Invoke pywebsocket through a wrapper which adds special SIGINT handling.
|
||||
#
|
||||
# If we're in an interactive debugger, the wrapper causes the server to
|
||||
# ignore SIGINT so the server doesn't capture a ctrl+c meant for the
|
||||
# debugger.
|
||||
#
|
||||
# If we're not in an interactive debugger, the wrapper causes the server to
|
||||
# die silently upon receiving a SIGINT.
|
||||
scriptPath = 'pywebsocket_wrapper.py'
|
||||
script = os.path.join(self._scriptdir, scriptPath)
|
||||
cmd = [sys.executable, script, '-p', str(self.port), '-w', self._scriptdir, '-l', os.path.join(self._scriptdir, "websock.log"), '--log-level=debug']
|
||||
|
||||
cmd = [sys.executable, script]
|
||||
if self.debuggerInfo and self.debuggerInfo['interactive']:
|
||||
cmd += ['--interactive']
|
||||
cmd += ['-p', str(self.port), '-w', self._scriptdir, '-l', os.path.join(self._scriptdir, "websock.log"), '--log-level=debug']
|
||||
|
||||
self._process = self._automation.Process(cmd)
|
||||
pid = self._process.pid
|
||||
@ -645,15 +651,19 @@ class Mochitest(object):
|
||||
self.startVMwareRecording(options);
|
||||
|
||||
self.automation.log.info("INFO | runtests.py | Running tests: start.\n")
|
||||
status = self.automation.runApp(testURL, browserEnv, options.app,
|
||||
options.profilePath, options.browserArgs,
|
||||
runSSLTunnel = self.runSSLTunnel,
|
||||
utilityPath = options.utilityPath,
|
||||
xrePath = options.xrePath,
|
||||
certPath=options.certPath,
|
||||
debuggerInfo=debuggerInfo,
|
||||
symbolsPath=options.symbolsPath,
|
||||
timeout = timeout)
|
||||
try:
|
||||
status = self.automation.runApp(testURL, browserEnv, options.app,
|
||||
options.profilePath, options.browserArgs,
|
||||
runSSLTunnel = self.runSSLTunnel,
|
||||
utilityPath = options.utilityPath,
|
||||
xrePath = options.xrePath,
|
||||
certPath=options.certPath,
|
||||
debuggerInfo=debuggerInfo,
|
||||
symbolsPath=options.symbolsPath,
|
||||
timeout = timeout)
|
||||
except KeyboardInterrupt:
|
||||
self.automation.log.info("INFO | runtests.py | Received keyboard interrupt.\n");
|
||||
status = -1
|
||||
|
||||
if options.vmwareRecording:
|
||||
self.stopVMwareRecording();
|
||||
|
Loading…
x
Reference in New Issue
Block a user