##// END OF EJS Templates
run-tests.py: fix handling of symlink to the right python...
Mads Kiilerich -
r18244:5a3c71b0 default
parent child Browse files
Show More
@@ -356,19 +356,19 b' def cleanup(options):'
356 def usecorrectpython():
356 def usecorrectpython():
357 # some tests run python interpreter. they must use same
357 # some tests run python interpreter. they must use same
358 # interpreter we use or bad things will happen.
358 # interpreter we use or bad things will happen.
359 exedir, exename = os.path.split(sys.executable)
359 pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
360 if exename in ('python', 'python.exe'):
361 path = findprogram(exename)
362 if os.path.dirname(path) == exedir:
363 return
364 else:
365 exename = 'python'
366 if sys.platform == 'win32':
367 exename = 'python.exe'
368 if getattr(os, 'symlink', None):
360 if getattr(os, 'symlink', None):
369 vlog("# Making python executable in test path a symlink to '%s'" %
361 vlog("# Making python executable in test path a symlink to '%s'" %
370 sys.executable)
362 sys.executable)
371 mypython = os.path.join(BINDIR, exename)
363 mypython = os.path.join(BINDIR, pyexename)
364 try:
365 if os.readlink(mypython) == sys.executable:
366 return
367 os.unlink(mypython)
368 except OSError, err:
369 if err.errno != errno.ENOENT:
370 raise
371 if findprogram(pyexename) != sys.executable:
372 try:
372 try:
373 os.symlink(sys.executable, mypython)
373 os.symlink(sys.executable, mypython)
374 except OSError, err:
374 except OSError, err:
@@ -376,13 +376,15 b' def usecorrectpython():'
376 if err.errno != errno.EEXIST:
376 if err.errno != errno.EEXIST:
377 raise
377 raise
378 else:
378 else:
379 vlog("# Modifying search path to find %s in '%s'" % (exename, exedir))
379 exedir, exename = os.path.split(sys.executable)
380 vlog("# Modifying search path to find %s as %s in '%s'" %
381 (exename, pyexename, exedir))
380 path = os.environ['PATH'].split(os.pathsep)
382 path = os.environ['PATH'].split(os.pathsep)
381 while exedir in path:
383 while exedir in path:
382 path.remove(exedir)
384 path.remove(exedir)
383 os.environ['PATH'] = os.pathsep.join([exedir] + path)
385 os.environ['PATH'] = os.pathsep.join([exedir] + path)
384 if not findprogram(exename):
386 if not findprogram(pyexename):
385 print "WARNING: Cannot find %s in search path" % exename
387 print "WARNING: Cannot find %s in search path" % pyexename
386
388
387 def installhg(options):
389 def installhg(options):
388 vlog("# Performing temporary installation of HG")
390 vlog("# Performing temporary installation of HG")
General Comments 0
You need to be logged in to leave comments. Login now