101 if 'java' in sys.platform: |
101 if 'java' in sys.platform: |
102 IMPL_PATH = 'JYTHONPATH' |
102 IMPL_PATH = 'JYTHONPATH' |
103 |
103 |
104 TESTDIR = HGTMP = INST = BINDIR = TMPBINDIR = PYTHONDIR = None |
104 TESTDIR = HGTMP = INST = BINDIR = TMPBINDIR = PYTHONDIR = None |
105 |
105 |
106 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip", |
|
107 "gunzip", "bunzip2", "sed"] |
|
108 defaults = { |
106 defaults = { |
109 'jobs': ('HGTEST_JOBS', 1), |
107 'jobs': ('HGTEST_JOBS', 1), |
110 'timeout': ('HGTEST_TIMEOUT', 180), |
108 'timeout': ('HGTEST_TIMEOUT', 180), |
111 'port': ('HGTEST_PORT', 20059), |
109 'port': ('HGTEST_PORT', 20059), |
112 'shell': ('HGTEST_SHELL', 'sh'), |
110 'shell': ('HGTEST_SHELL', 'sh'), |
333 print m, |
331 print m, |
334 print |
332 print |
335 sys.stdout.flush() |
333 sys.stdout.flush() |
336 iolock.release() |
334 iolock.release() |
337 |
335 |
338 def findprogram(program): |
|
339 """Search PATH for a executable program""" |
|
340 for p in os.environ.get('PATH', os.defpath).split(os.pathsep): |
|
341 name = os.path.join(p, program) |
|
342 if os.name == 'nt' or os.access(name, os.X_OK): |
|
343 return name |
|
344 return None |
|
345 |
|
346 def createhgrc(path, options): |
336 def createhgrc(path, options): |
347 # create a fresh hgrc |
337 # create a fresh hgrc |
348 hgrc = open(path, 'w') |
338 hgrc = open(path, 'w') |
349 hgrc.write('[ui]\n') |
339 hgrc.write('[ui]\n') |
350 hgrc.write('slash = True\n') |
340 hgrc.write('slash = True\n') |
359 section, key = opt.split('.', 1) |
349 section, key = opt.split('.', 1) |
360 assert '=' in key, ('extra config opt %s must ' |
350 assert '=' in key, ('extra config opt %s must ' |
361 'have an = for assignment' % opt) |
351 'have an = for assignment' % opt) |
362 hgrc.write('[%s]\n%s\n' % (section, key)) |
352 hgrc.write('[%s]\n%s\n' % (section, key)) |
363 hgrc.close() |
353 hgrc.close() |
364 |
|
365 def checktools(): |
|
366 # Before we go any further, check for pre-requisite tools |
|
367 # stuff from coreutils (cat, rm, etc) are not tested |
|
368 for p in requiredtools: |
|
369 if os.name == 'nt' and not p.endswith('.exe'): |
|
370 p += '.exe' |
|
371 found = findprogram(p) |
|
372 if found: |
|
373 vlog("# Found prerequisite", p, "at", found) |
|
374 else: |
|
375 print "WARNING: Did not find prerequisite tool: "+p |
|
376 |
354 |
377 def terminate(proc): |
355 def terminate(proc): |
378 """Terminate subprocess (with fallback for Python versions < 2.6)""" |
356 """Terminate subprocess (with fallback for Python versions < 2.6)""" |
379 vlog('# Terminating process %d' % proc.pid) |
357 vlog('# Terminating process %d' % proc.pid) |
380 try: |
358 try: |
1144 return |
1132 return |
1145 os.unlink(mypython) |
1133 os.unlink(mypython) |
1146 except OSError, err: |
1134 except OSError, err: |
1147 if err.errno != errno.ENOENT: |
1135 if err.errno != errno.ENOENT: |
1148 raise |
1136 raise |
1149 if findprogram(pyexename) != sys.executable: |
1137 if self._findprogram(pyexename) != sys.executable: |
1150 try: |
1138 try: |
1151 os.symlink(sys.executable, mypython) |
1139 os.symlink(sys.executable, mypython) |
1152 self._createdfiles.append(mypython) |
1140 self._createdfiles.append(mypython) |
1153 except OSError, err: |
1141 except OSError, err: |
1154 # child processes may race, which is harmless |
1142 # child processes may race, which is harmless |
1160 (exename, pyexename, exedir)) |
1148 (exename, pyexename, exedir)) |
1161 path = os.environ['PATH'].split(os.pathsep) |
1149 path = os.environ['PATH'].split(os.pathsep) |
1162 while exedir in path: |
1150 while exedir in path: |
1163 path.remove(exedir) |
1151 path.remove(exedir) |
1164 os.environ['PATH'] = os.pathsep.join([exedir] + path) |
1152 os.environ['PATH'] = os.pathsep.join([exedir] + path) |
1165 if not findprogram(pyexename): |
1153 if not self._findprogram(pyexename): |
1166 print "WARNING: Cannot find %s in search path" % pyexename |
1154 print "WARNING: Cannot find %s in search path" % pyexename |
1167 |
1155 |
1168 def installhg(self): |
1156 def installhg(self): |
1169 vlog("# Performing temporary installation of HG") |
1157 vlog("# Performing temporary installation of HG") |
1170 installerrs = os.path.join("tests", "install.err") |
1158 installerrs = os.path.join("tests", "install.err") |
1329 running += 1 |
1317 running += 1 |
1330 count += 1 |
1318 count += 1 |
1331 except KeyboardInterrupt: |
1319 except KeyboardInterrupt: |
1332 self.abort[0] = True |
1320 self.abort[0] = True |
1333 |
1321 |
|
1322 def _findprogram(self, program): |
|
1323 """Search PATH for a executable program""" |
|
1324 for p in os.environ.get('PATH', os.defpath).split(os.pathsep): |
|
1325 name = os.path.join(p, program) |
|
1326 if os.name == 'nt' or os.access(name, os.X_OK): |
|
1327 return name |
|
1328 return None |
|
1329 |
|
1330 def checktools(self): |
|
1331 # Before we go any further, check for pre-requisite tools |
|
1332 # stuff from coreutils (cat, rm, etc) are not tested |
|
1333 for p in self.REQUIREDTOOLS: |
|
1334 if os.name == 'nt' and not p.endswith('.exe'): |
|
1335 p += '.exe' |
|
1336 found = self._findprogram(p) |
|
1337 if found: |
|
1338 vlog("# Found prerequisite", p, "at", found) |
|
1339 else: |
|
1340 print "WARNING: Did not find prerequisite tool: %s " % p |
|
1341 |
1334 def main(args, runner=None, parser=None): |
1342 def main(args, runner=None, parser=None): |
1335 runner = runner or TestRunner() |
1343 runner = runner or TestRunner() |
1336 |
1344 |
1337 parser = parser or getparser() |
1345 parser = parser or getparser() |
1338 (options, args) = parseargs(args, parser) |
1346 (options, args) = parseargs(args, parser) |
1339 runner.options = options |
1347 runner.options = options |
1340 os.umask(022) |
1348 os.umask(022) |
1341 |
1349 |
1342 checktools() |
1350 runner.checktools() |
1343 |
1351 |
1344 tests = runner.findtests(args) |
1352 tests = runner.findtests(args) |
1345 |
1353 |
1346 if options.random: |
1354 if options.random: |
1347 random.shuffle(tests) |
1355 random.shuffle(tests) |