Have runxpcshell ignore SIGINT, so we can CTRL-C hung tests and get stdout/stderr from test.
authorJason Duell <jduell.mcbugs@gmail.com>
Sat, 31 Oct 2009 02:58:14 +0100
changeset 34434 38af610d3e758bd17c56b33df0a8716f6c6a6278
parent 34433 aaaa9779a9a26627deeb738e807007ea65914a4b
child 34435 7f6e2f4abdfda3a2786cdb96dc6cb3b1f268a167
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs520649
milestone1.9.3a1pre
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
testing/xpcshell/runxpcshelltests.py
--- 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:
   >>>>>>>