tests/run-tests.py
branchstable
changeset 878 e1a93489159d
parent 877 c2ca6e172fd8
child 880 0b9f0c42b566
equal deleted inserted replaced
877:c2ca6e172fd8 878:e1a93489159d
   578     if pos in after:
   578     if pos in after:
   579         postout += after.pop(pos)
   579         postout += after.pop(pos)
   580 
   580 
   581     return exitcode, postout
   581     return exitcode, postout
   582 
   582 
       
   583 wifexited = getattr(os, "WIFEXITED", lambda x: False)
   583 def run(cmd, options, replacements):
   584 def run(cmd, options, replacements):
   584     """Run command in a sub-process, capturing the output (stdout and stderr).
   585     """Run command in a sub-process, capturing the output (stdout and stderr).
   585     Return a tuple (exitcode, output).  output is None in debug mode."""
   586     Return a tuple (exitcode, output).  output is None in debug mode."""
   586     # TODO: Use subprocess.Popen if we're running on Python 2.4
   587     # TODO: Use subprocess.Popen if we're running on Python 2.4
   587     if options.debug:
   588     if options.debug:
   609         try:
   610         try:
   610             output = ''
   611             output = ''
   611             proc.tochild.close()
   612             proc.tochild.close()
   612             output = proc.fromchild.read()
   613             output = proc.fromchild.read()
   613             ret = proc.wait()
   614             ret = proc.wait()
   614             if os.WIFEXITED(ret):
   615             if wifexited(ret):
   615                 ret = os.WEXITSTATUS(ret)
   616                 ret = os.WEXITSTATUS(ret)
   616         except Timeout:
   617         except Timeout:
   617             vlog('# Process %d timed out - killing it' % proc.pid)
   618             vlog('# Process %d timed out - killing it' % proc.pid)
   618             ret = cleanup()
   619             ret = cleanup()
   619             output += ("\n### Abort: timeout after %d seconds.\n"
   620             output += ("\n### Abort: timeout after %d seconds.\n"