comparison tests/run-tests.py @ 2569:2264b2b077a1

run-tests.py: make tests use same python interpreter as test harness. this is wanted because some tests run python interpreter directly. must use same python interpreter in tests as in main harness or problems will happen because of e.g. different python abi if run-tests.py run with python 2.5 but system python is 2.4. fix is to see if system python is used and is named python. if no, put symlink called python at front of shell search path.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 06 Jul 2006 10:09:24 -0700
parents 4068d6a7a99e
children 83cfd95eafb5
comparison
equal deleted inserted replaced
2568:52ce0d6bc375 2569:2264b2b077a1
77 def cleanup_exit(): 77 def cleanup_exit():
78 if verbose: 78 if verbose:
79 print "# Cleaning up HGTMP", HGTMP 79 print "# Cleaning up HGTMP", HGTMP
80 shutil.rmtree(HGTMP, True) 80 shutil.rmtree(HGTMP, True)
81 81
82 def use_correct_python():
83 # some tests run python interpreter. they must use same
84 # interpreter we use or bad things will happen.
85 exedir, exename = os.path.split(sys.executable)
86 if exename == 'python':
87 path = find_program('python')
88 if os.path.dirname(path) == exedir:
89 return
90 vlog('# Making python executable in test path use correct Python')
91 my_python = os.path.join(BINDIR, 'python')
92 try:
93 os.symlink(sys.executable, my_python)
94 except AttributeError:
95 # windows fallback
96 shutil.copyfile(sys.executable, my_python)
97 shutil.copymode(sys.executable, my_python)
98
82 def install_hg(): 99 def install_hg():
83 vlog("# Performing temporary installation of HG") 100 vlog("# Performing temporary installation of HG")
84 installerrs = os.path.join("tests", "install.err") 101 installerrs = os.path.join("tests", "install.err")
85 102
86 os.chdir("..") # Get back to hg root 103 os.chdir("..") # Get back to hg root
99 sys.exit(1) 116 sys.exit(1)
100 os.chdir(TESTDIR) 117 os.chdir(TESTDIR)
101 118
102 os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"]) 119 os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"])
103 os.environ["PYTHONPATH"] = PYTHONDIR 120 os.environ["PYTHONPATH"] = PYTHONDIR
121
122 use_correct_python()
104 123
105 if coverage: 124 if coverage:
106 vlog("# Installing coverage wrapper") 125 vlog("# Installing coverage wrapper")
107 os.environ['COVERAGE_FILE'] = COVERAGE_FILE 126 os.environ['COVERAGE_FILE'] = COVERAGE_FILE
108 if os.path.exists(COVERAGE_FILE): 127 if os.path.exists(COVERAGE_FILE):