tests/run-tests.py
branchstable
changeset 942 92325072c4d4
parent 936 7a8ae4eb18bf
child 943 1f7fd6db1e17
equal deleted inserted replaced
940:4bd06014631e 942:92325072c4d4
   314 
   314 
   315 def findprogram(program):
   315 def findprogram(program):
   316     """Search PATH for a executable program"""
   316     """Search PATH for a executable program"""
   317     for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
   317     for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
   318         name = os.path.join(p, program)
   318         name = os.path.join(p, program)
   319         if os.access(name, os.X_OK):
   319         if os.name == 'nt' or os.access(name, os.X_OK):
   320             return name
   320             return name
   321     return None
   321     return None
   322 
   322 
   323 def checktools():
   323 def checktools():
   324     # Before we go any further, check for pre-requisite tools
   324     # Before we go any further, check for pre-requisite tools
   364 
   364 
   365 def usecorrectpython():
   365 def usecorrectpython():
   366     # some tests run python interpreter. they must use same
   366     # some tests run python interpreter. they must use same
   367     # interpreter we use or bad things will happen.
   367     # interpreter we use or bad things will happen.
   368     exedir, exename = os.path.split(sys.executable)
   368     exedir, exename = os.path.split(sys.executable)
   369     if exename == 'python':
   369     if exename in ('python', 'python.exe'):
   370         path = findprogram('python')
   370         path = findprogram(exename)
   371         if os.path.dirname(path) == exedir:
   371         if os.path.dirname(path) == exedir:
   372             return
   372             return
       
   373     else:
       
   374         exename = 'python'
   373     vlog('# Making python executable in test path use correct Python')
   375     vlog('# Making python executable in test path use correct Python')
   374     mypython = os.path.join(BINDIR, 'python')
   376     mypython = os.path.join(BINDIR, exename)
   375     try:
   377     try:
   376         os.symlink(sys.executable, mypython)
   378         os.symlink(sys.executable, mypython)
   377     except AttributeError:
   379     except AttributeError:
   378         # windows fallback
   380         # windows fallback
   379         shutil.copyfile(sys.executable, mypython)
   381         shutil.copyfile(sys.executable, mypython)