tests/run-tests.py
branchstable
changeset 945 83e828101e3c
parent 944 37aff8ccb33e
child 946 b6a39effa432
equal deleted inserted replaced
944:37aff8ccb33e 945:83e828101e3c
   640     if options.debug:
   640     if options.debug:
   641         proc = subprocess.Popen(cmd, shell=True)
   641         proc = subprocess.Popen(cmd, shell=True)
   642         ret = proc.wait()
   642         ret = proc.wait()
   643         return (ret, None)
   643         return (ret, None)
   644 
   644 
   645     if os.name == 'nt' or sys.platform.startswith('java'):
   645     proc = Popen4(cmd, wd, options.timeout)
   646         tochild, fromchild = os.popen4(cmd)
   646     def cleanup():
   647         tochild.close()
       
   648         output = fromchild.read()
       
   649         ret = fromchild.close()
       
   650         if ret is None:
       
   651             ret = 0
       
   652     else:
       
   653         proc = Popen4(cmd, wd, options.timeout)
       
   654         def cleanup():
       
   655             try:
       
   656                 proc.terminate()
       
   657             except OSError:
       
   658                 pass
       
   659             ret = proc.wait()
       
   660             if ret == 0:
       
   661                 ret = signal.SIGTERM << 8
       
   662             killdaemons()
       
   663             return ret
       
   664 
       
   665         output = ''
       
   666         proc.tochild.close()
       
   667 
       
   668         try:
   647         try:
   669             output = proc.fromchild.read()
   648             proc.terminate()
   670         except KeyboardInterrupt:
   649         except OSError:
   671             vlog('# Handling keyboard interrupt')
   650             pass
   672             cleanup()
       
   673             raise
       
   674 
       
   675         ret = proc.wait()
   651         ret = proc.wait()
   676         if wifexited(ret):
   652         if ret == 0:
   677             ret = os.WEXITSTATUS(ret)
   653             ret = signal.SIGTERM << 8
   678 
   654         killdaemons()
   679         if proc.timeout:
   655         return ret
   680             ret = 'timeout'
   656 
   681 
   657     output = ''
   682         if ret:
   658     proc.tochild.close()
   683             killdaemons()
   659 
       
   660     try:
       
   661         output = proc.fromchild.read()
       
   662     except KeyboardInterrupt:
       
   663         vlog('# Handling keyboard interrupt')
       
   664         cleanup()
       
   665         raise
       
   666 
       
   667     ret = proc.wait()
       
   668     if wifexited(ret):
       
   669         ret = os.WEXITSTATUS(ret)
       
   670 
       
   671     if proc.timeout:
       
   672         ret = 'timeout'
       
   673 
       
   674     if ret:
       
   675         killdaemons()
   684 
   676 
   685     for s, r in replacements:
   677     for s, r in replacements:
   686         output = re.sub(s, r, output)
   678         output = re.sub(s, r, output)
   687     return ret, splitnewlines(output)
   679     return ret, splitnewlines(output)
   688 
   680