Show More
@@ -205,7 +205,6 b' def usecorrectpython():' | |||||
205 | shutil.copymode(sys.executable, mypython) |
|
205 | shutil.copymode(sys.executable, mypython) | |
206 |
|
206 | |||
207 | def installhg(options): |
|
207 | def installhg(options): | |
208 | global PYTHON |
|
|||
209 | vlog("# Performing temporary installation of HG") |
|
208 | vlog("# Performing temporary installation of HG") | |
210 | installerrs = os.path.join("tests", "install.err") |
|
209 | installerrs = os.path.join("tests", "install.err") | |
211 | pure = options.pure and "--pure" or "" |
|
210 | pure = options.pure and "--pure" or "" | |
@@ -239,8 +238,6 b' def installhg(options):' | |||||
239 | os.environ["PYTHONPATH"] = pythonpath |
|
238 | os.environ["PYTHONPATH"] = pythonpath | |
240 |
|
239 | |||
241 | usecorrectpython() |
|
240 | usecorrectpython() | |
242 | global hgpkg |
|
|||
243 | hgpkg = _hgpath() |
|
|||
244 |
|
241 | |||
245 | vlog("# Installing dummy diffstat") |
|
242 | vlog("# Installing dummy diffstat") | |
246 | f = open(os.path.join(BINDIR, 'diffstat'), 'w') |
|
243 | f = open(os.path.join(BINDIR, 'diffstat'), 'w') | |
@@ -269,15 +266,6 b' def installhg(options):' | |||||
269 | os.path.join(BINDIR, '_hg.py'))) |
|
266 | os.path.join(BINDIR, '_hg.py'))) | |
270 | f.close() |
|
267 | f.close() | |
271 | os.chmod(os.path.join(BINDIR, 'hg'), 0700) |
|
268 | os.chmod(os.path.join(BINDIR, 'hg'), 0700) | |
272 | PYTHON = '"%s" "%s" -x -p' % (sys.executable, |
|
|||
273 | os.path.join(TESTDIR, 'coverage.py')) |
|
|||
274 |
|
||||
275 | def _hgpath(): |
|
|||
276 | cmd = '%s -c "import mercurial; print mercurial.__path__[0]"' |
|
|||
277 | hgpath = os.popen(cmd % PYTHON) |
|
|||
278 | path = hgpath.read().strip() |
|
|||
279 | hgpath.close() |
|
|||
280 | return path |
|
|||
281 |
|
269 | |||
282 | def outputcoverage(options): |
|
270 | def outputcoverage(options): | |
283 |
|
271 | |||
@@ -496,11 +484,35 b' def runone(options, test, skips, fails):' | |||||
496 | return None |
|
484 | return None | |
497 | return ret == 0 |
|
485 | return ret == 0 | |
498 |
|
486 | |||
499 | def runchildren(options, expecthg, tests): |
|
487 | _hgpath = None | |
|
488 | ||||
|
489 | def _gethgpath(): | |||
|
490 | """Return the path to the mercurial package that is actually found by | |||
|
491 | the current Python interpreter.""" | |||
|
492 | global _hgpath | |||
|
493 | if _hgpath is not None: | |||
|
494 | return _hgpath | |||
|
495 | ||||
|
496 | cmd = '%s -c "import mercurial; print mercurial.__path__[0]"' | |||
|
497 | pipe = os.popen(cmd % PYTHON) | |||
|
498 | try: | |||
|
499 | _hgpath = pipe.read().strip() | |||
|
500 | finally: | |||
|
501 | pipe.close() | |||
|
502 | return _hgpath | |||
|
503 | ||||
|
504 | def _checkhglib(verb): | |||
|
505 | """Ensure that the 'mercurial' package imported by python is | |||
|
506 | the one we expect it to be. If not, print a message to stdout.""" | |||
|
507 | expecthg = os.path.join(HGTMP, 'install', 'lib', 'python', 'mercurial') | |||
|
508 | actualhg = _gethgpath() | |||
|
509 | if actualhg != expecthg: | |||
|
510 | print '# %s unexpected mercurial: %s' % (verb, actualhg) | |||
|
511 | ||||
|
512 | def runchildren(options, tests): | |||
500 | if not options.with_hg: |
|
513 | if not options.with_hg: | |
501 | installhg(options) |
|
514 | installhg(options) | |
502 | if hgpkg != expecthg: |
|
515 | _checkhglib("Testing") | |
503 | print '# Testing unexpected mercurial: %s' % hgpkg |
|
|||
504 |
|
516 | |||
505 | optcopy = dict(options.__dict__) |
|
517 | optcopy = dict(options.__dict__) | |
506 | optcopy['jobs'] = 1 |
|
518 | optcopy['jobs'] = 1 | |
@@ -554,13 +566,12 b' def runchildren(options, expecthg, tests' | |||||
554 | for s in fails: |
|
566 | for s in fails: | |
555 | print "Failed %s: %s" % (s[0], s[1]) |
|
567 | print "Failed %s: %s" % (s[0], s[1]) | |
556 |
|
568 | |||
557 | if hgpkg != expecthg: |
|
569 | _checkhglib("Tested") | |
558 | print '# Tested unexpected mercurial: %s' % hgpkg |
|
|||
559 | print "# Ran %d tests, %d skipped, %d failed." % ( |
|
570 | print "# Ran %d tests, %d skipped, %d failed." % ( | |
560 | tested, skipped, failed) |
|
571 | tested, skipped, failed) | |
561 | sys.exit(failures != 0) |
|
572 | sys.exit(failures != 0) | |
562 |
|
573 | |||
563 |
def runtests(options, |
|
574 | def runtests(options, tests): | |
564 | global DAEMON_PIDS, HGRCPATH |
|
575 | global DAEMON_PIDS, HGRCPATH | |
565 | DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
|
576 | DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') | |
566 | HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
|
577 | HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') | |
@@ -568,9 +579,7 b' def runtests(options, expecthg, tests):' | |||||
568 | try: |
|
579 | try: | |
569 | if not options.with_hg: |
|
580 | if not options.with_hg: | |
570 | installhg(options) |
|
581 | installhg(options) | |
571 |
|
582 | _checkhglib("Testing") | ||
572 | if hgpkg != expecthg: |
|
|||
573 | print '# Testing unexpected mercurial: %s' % hgpkg |
|
|||
574 |
|
583 | |||
575 | if options.timeout > 0: |
|
584 | if options.timeout > 0: | |
576 | try: |
|
585 | try: | |
@@ -632,8 +641,7 b' def runtests(options, expecthg, tests):' | |||||
632 | print "Skipped %s: %s" % s |
|
641 | print "Skipped %s: %s" % s | |
633 | for s in fails: |
|
642 | for s in fails: | |
634 | print "Failed %s: %s" % s |
|
643 | print "Failed %s: %s" % s | |
635 | if hgpkg != expecthg: |
|
644 | _checkhglib("Tested") | |
636 | print '# Tested unexpected mercurial: %s' % hgpkg |
|
|||
637 | print "# Ran %d tests, %d skipped, %d failed." % ( |
|
645 | print "# Ran %d tests, %d skipped, %d failed." % ( | |
638 | tested, skipped, failed) |
|
646 | tested, skipped, failed) | |
639 |
|
647 | |||
@@ -684,8 +692,6 b' def main():' | |||||
684 | PYTHONDIR = os.path.join(INST, "lib", "python") |
|
692 | PYTHONDIR = os.path.join(INST, "lib", "python") | |
685 | COVERAGE_FILE = os.path.join(TESTDIR, ".coverage") |
|
693 | COVERAGE_FILE = os.path.join(TESTDIR, ".coverage") | |
686 |
|
694 | |||
687 | expecthg = os.path.join(HGTMP, 'install', 'lib', 'python', 'mercurial') |
|
|||
688 |
|
||||
689 | if len(args) == 0: |
|
695 | if len(args) == 0: | |
690 | args = os.listdir(".") |
|
696 | args = os.listdir(".") | |
691 | args.sort() |
|
697 | args.sort() | |
@@ -705,9 +711,9 b' def main():' | |||||
705 |
|
711 | |||
706 | try: |
|
712 | try: | |
707 | if len(tests) > 1 and options.jobs > 1: |
|
713 | if len(tests) > 1 and options.jobs > 1: | |
708 |
runchildren(options, |
|
714 | runchildren(options, tests) | |
709 | else: |
|
715 | else: | |
710 |
runtests(options, |
|
716 | runtests(options, tests) | |
711 | finally: |
|
717 | finally: | |
712 | cleanup(options) |
|
718 | cleanup(options) | |
713 |
|
719 |
General Comments 0
You need to be logged in to leave comments.
Login now