432 # interpreter we use or bad things will happen. |
432 # interpreter we use or bad things will happen. |
433 pyexename = sys.platform == 'win32' and 'python.exe' or 'python' |
433 pyexename = sys.platform == 'win32' and 'python.exe' or 'python' |
434 if getattr(os, 'symlink', None): |
434 if getattr(os, 'symlink', None): |
435 vlog("# Making python executable in test path a symlink to '%s'" % |
435 vlog("# Making python executable in test path a symlink to '%s'" % |
436 sys.executable) |
436 sys.executable) |
437 mypython = os.path.join(BINDIR, pyexename) |
437 mypython = os.path.join(TMPBINDIR, pyexename) |
438 try: |
438 try: |
439 if os.readlink(mypython) == sys.executable: |
439 if os.readlink(mypython) == sys.executable: |
440 return |
440 return |
441 os.unlink(mypython) |
441 os.unlink(mypython) |
442 except OSError, err: |
442 except OSError, err: |
1213 if 'PYTHONHASHSEED' not in os.environ: |
1213 if 'PYTHONHASHSEED' not in os.environ: |
1214 # use a random python hash seed all the time |
1214 # use a random python hash seed all the time |
1215 # we do the randomness ourself to know what seed is used |
1215 # we do the randomness ourself to know what seed is used |
1216 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
1216 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
1217 |
1217 |
1218 global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE |
1218 global TESTDIR, HGTMP, INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE |
1219 TESTDIR = os.environ["TESTDIR"] = os.getcwd() |
1219 TESTDIR = os.environ["TESTDIR"] = os.getcwd() |
1220 if options.tmpdir: |
1220 if options.tmpdir: |
1221 options.keep_tmpdir = True |
1221 options.keep_tmpdir = True |
1222 tmpdir = options.tmpdir |
1222 tmpdir = options.tmpdir |
1223 if os.path.exists(tmpdir): |
1223 if os.path.exists(tmpdir): |
1242 HGTMP = os.environ['HGTMP'] = os.path.realpath(tmpdir) |
1242 HGTMP = os.environ['HGTMP'] = os.path.realpath(tmpdir) |
1243 |
1243 |
1244 if options.with_hg: |
1244 if options.with_hg: |
1245 INST = None |
1245 INST = None |
1246 BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) |
1246 BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) |
|
1247 TMPBINDIR = os.path.join(HGTMP, 'install', 'bin') |
|
1248 os.makedirs(TMPBINDIR) |
1247 |
1249 |
1248 # This looks redundant with how Python initializes sys.path from |
1250 # This looks redundant with how Python initializes sys.path from |
1249 # the location of the script being executed. Needed because the |
1251 # the location of the script being executed. Needed because the |
1250 # "hg" specified by --with-hg is not the only Python script |
1252 # "hg" specified by --with-hg is not the only Python script |
1251 # executed in the test suite that needs to import 'mercurial' |
1253 # executed in the test suite that needs to import 'mercurial' |
1252 # ... which means it's not really redundant at all. |
1254 # ... which means it's not really redundant at all. |
1253 PYTHONDIR = BINDIR |
1255 PYTHONDIR = BINDIR |
1254 else: |
1256 else: |
1255 INST = os.path.join(HGTMP, "install") |
1257 INST = os.path.join(HGTMP, "install") |
1256 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin") |
1258 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin") |
|
1259 TMPBINDIR = BINDIR |
1257 PYTHONDIR = os.path.join(INST, "lib", "python") |
1260 PYTHONDIR = os.path.join(INST, "lib", "python") |
1258 |
1261 |
1259 os.environ["BINDIR"] = BINDIR |
1262 os.environ["BINDIR"] = BINDIR |
1260 os.environ["PYTHON"] = PYTHON |
1263 os.environ["PYTHON"] = PYTHON |
1261 |
1264 |
1262 path = [BINDIR] + os.environ["PATH"].split(os.pathsep) |
1265 path = [BINDIR] + os.environ["PATH"].split(os.pathsep) |
|
1266 if TMPBINDIR != BINDIR: |
|
1267 path = [TMPBINDIR] + path |
1263 os.environ["PATH"] = os.pathsep.join(path) |
1268 os.environ["PATH"] = os.pathsep.join(path) |
1264 |
1269 |
1265 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
1270 # Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
1266 # can run .../tests/run-tests.py test-foo where test-foo |
1271 # can run .../tests/run-tests.py test-foo where test-foo |
1267 # adds an extension to HGRC. Also include run-test.py directory to import |
1272 # adds an extension to HGRC. Also include run-test.py directory to import |