Have runxpcshell ignore SIGINT, so we can CTRL-C hung tests and get stdout/stderr from test.
Have runxpcshell ignore SIGINT, so we can CTRL-C hung tests and get stdout/stderr from test.
Bug 520649 - runxpcshelltests.py should propagate SIGINT to unit tests.
r=jwalden
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -32,17 +32,17 @@
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK ***** */
-import re, sys, os, os.path, logging, shutil
+import re, sys, os, os.path, logging, shutil, signal
from glob import glob
from optparse import OptionParser
from subprocess import Popen, PIPE, STDOUT
from tempfile import mkdtemp
from automationutils import *
# Init logging
@@ -227,18 +227,23 @@ def runTests(xpcshell, xrePath=None, sym
env["XPCSHELL_TEST_PROFILE_DIR"] = profileDir
# Enable leaks (only) detection to its own log file.
leakLogFile = os.path.join(profileDir, "runxpcshelltests_leaks.log")
env["XPCOM_MEM_LEAK_LOG"] = leakLogFile
proc = Popen(cmdH + cmdT + xpcsRunArgs,
stdout=pStdout, stderr=pStderr, env=env, cwd=testdir)
+
+ # allow user to kill hung subprocess with SIGINT w/o killing this script
+ # - don't move this line above Popen, or child will inherit the SIG_IGN
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
# |stderr == None| as |pStderr| was either |None| or redirected to |stdout|.
stdout, stderr = proc.communicate()
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
if interactive:
# Not sure what else to do here...
return True
if proc.returncode != 0 or (stdout and re.search("^TEST-UNEXPECTED-FAIL", stdout, re.MULTILINE)):
print """TEST-UNEXPECTED-FAIL | %s | test failed (with xpcshell return code: %d), see following log:
>>>>>>>