tests/run-tests.py
changeset 7813 076401cf2b63
parent 7792 cf427b04d5c0
child 8060 84d0fe34427b
equal deleted inserted replaced
7812:18048153fd4e 7813:076401cf2b63
     9 
     9 
    10 import difflib
    10 import difflib
    11 import errno
    11 import errno
    12 import optparse
    12 import optparse
    13 import os
    13 import os
    14 import popen2
    14 try:
       
    15     import subprocess
       
    16     subprocess.Popen  # trigger ImportError early
       
    17     closefds = os.name == 'posix'
       
    18     def Popen4(cmd, bufsize=-1):
       
    19         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
       
    20                              close_fds=closefds,
       
    21                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
       
    22                              stderr=subprocess.STDOUT)
       
    23         p.fromchild = p.stdout
       
    24         p.tochild = p.stdin
       
    25         p.childerr = p.stderr
       
    26         return p
       
    27 except ImportError:
       
    28     subprocess = None
       
    29     from popen2 import Popen4
    15 import shutil
    30 import shutil
    16 import signal
    31 import signal
    17 import sys
    32 import sys
    18 import tempfile
    33 import tempfile
    19 import time
    34 import time
   279         output = fromchild.read()
   294         output = fromchild.read()
   280         ret = fromchild.close()
   295         ret = fromchild.close()
   281         if ret == None:
   296         if ret == None:
   282             ret = 0
   297             ret = 0
   283     else:
   298     else:
   284         proc = popen2.Popen4(cmd)
   299         proc = Popen4(cmd)
   285         try:
   300         try:
   286             output = ''
   301             output = ''
   287             proc.tochild.close()
   302             proc.tochild.close()
   288             output = proc.fromchild.read()
   303             output = proc.fromchild.read()
   289             ret = proc.wait()
   304             ret = proc.wait()