631 |
631 |
632 for s, r in replacements: |
632 for s, r in replacements: |
633 output = re.sub(s, r, output) |
633 output = re.sub(s, r, output) |
634 return ret, splitnewlines(output) |
634 return ret, splitnewlines(output) |
635 |
635 |
636 def runone(options, test, skips, passes, fails, ignores): |
636 def runone(options, test, results): |
637 '''tristate output: |
637 '''tristate output: |
638 None -> skipped |
638 None -> skipped |
639 True -> passed |
639 True -> passed |
640 False -> failed''' |
640 False -> failed''' |
641 |
641 |
642 testpath = os.path.join(TESTDIR, test) |
642 testpath = os.path.join(TESTDIR, test) |
643 |
643 |
644 def skip(msg): |
644 def skip(msg): |
645 if not options.verbose: |
645 if not options.verbose: |
646 skips.append((test, msg)) |
646 results['s'].append((test, msg)) |
647 else: |
647 else: |
648 print "\nSkipping %s: %s" % (testpath, msg) |
648 print "\nSkipping %s: %s" % (testpath, msg) |
649 return None |
649 return None |
650 |
650 |
651 def fail(msg, ret): |
651 def fail(msg, ret): |
658 if test.endswith(".t"): |
658 if test.endswith(".t"): |
659 rename(test + ".err", test) |
659 rename(test + ".err", test) |
660 else: |
660 else: |
661 rename(test + ".err", test + ".out") |
661 rename(test + ".err", test + ".out") |
662 return |
662 return |
663 fails.append((test, msg)) |
663 results['f'].append((test, msg)) |
|
664 |
|
665 def success(): |
|
666 results['p'].append(test) |
|
667 |
|
668 def ignore(msg): |
|
669 results['i'].append((test, msg)) |
664 |
670 |
665 if (test.startswith("test-") and '~' not in test and |
671 if (test.startswith("test-") and '~' not in test and |
666 ('.' not in test or test.endswith('.py') or |
672 ('.' not in test or test.endswith('.py') or |
667 test.endswith('.bat') or test.endswith('.t'))): |
673 test.endswith('.bat') or test.endswith('.t'))): |
668 if not os.path.exists(test): |
674 if not os.path.exists(test): |
676 if filename is not None: |
682 if filename is not None: |
677 skipped.append((test, "blacklisted (%s)" % filename)) |
683 skipped.append((test, "blacklisted (%s)" % filename)) |
678 return None |
684 return None |
679 |
685 |
680 if options.retest and not os.path.exists(test + ".err"): |
686 if options.retest and not os.path.exists(test + ".err"): |
681 ignores.append((test, "not retesting")) |
687 ignore("not retesting") |
682 return None |
688 return None |
683 |
689 |
684 if options.keywords: |
690 if options.keywords: |
685 fp = open(test) |
691 fp = open(test) |
686 t = fp.read().lower() + test.lower() |
692 t = fp.read().lower() + test.lower() |
687 fp.close() |
693 fp.close() |
688 for k in options.keywords.lower().split(): |
694 for k in options.keywords.lower().split(): |
689 if k in t: |
695 if k in t: |
690 break |
696 break |
691 else: |
697 else: |
692 ignores.append((test, "doesn't match keyword")) |
698 ignore("doesn't match keyword") |
693 return None |
699 return None |
694 |
700 |
695 vlog("# Test", test) |
701 vlog("# Test", test) |
696 |
702 |
697 # create a fresh hgrc |
703 # create a fresh hgrc |
931 def runtests(options, tests): |
937 def runtests(options, tests): |
932 global DAEMON_PIDS, HGRCPATH |
938 global DAEMON_PIDS, HGRCPATH |
933 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
939 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
934 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
940 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
935 |
941 |
|
942 results = dict(p=[], f=[], s=[], i=[]) |
|
943 |
936 try: |
944 try: |
937 if INST: |
945 if INST: |
938 installhg(options) |
946 installhg(options) |
939 _checkhglib("Testing") |
947 _checkhglib("Testing") |
940 |
948 |
955 tests.pop(0) |
963 tests.pop(0) |
956 if not tests: |
964 if not tests: |
957 print "running all tests" |
965 print "running all tests" |
958 tests = orig |
966 tests = orig |
959 |
967 |
960 passes = [] |
|
961 skips = [] |
|
962 fails = [] |
|
963 ignores = [] |
|
964 |
|
965 for test in tests: |
968 for test in tests: |
966 ret = runone(options, test, skips, passes, fails, ignores) |
969 ret = runone(options, test, results) |
967 if options.first and ret is not None and not ret: |
970 if options.first and ret is not None and not ret: |
968 break |
971 break |
|
972 |
|
973 failed = len(results['f']) |
|
974 tested = len(results['p']) + failed |
|
975 skipped = len(results['s']) |
|
976 ignored = len(results['i']) |
969 |
977 |
970 if options.child: |
978 if options.child: |
971 fp = os.fdopen(options.child, 'w') |
979 fp = os.fdopen(options.child, 'w') |
972 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed)) |
980 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed)) |
973 for s in skips: |
981 for s in results['s']: |
974 fp.write("%s %s\n" % s) |
982 fp.write("%s %s\n" % s) |
975 for s in fails: |
983 for s in results['f']: |
976 fp.write("%s %s\n" % s) |
984 fp.write("%s %s\n" % s) |
977 fp.close() |
985 fp.close() |
978 else: |
986 else: |
979 print |
987 print |
980 for s in skips: |
988 for s in results['s']: |
981 print "Skipped %s: %s" % s |
989 print "Skipped %s: %s" % s |
982 for s in fails: |
990 for s in results['f']: |
983 print "Failed %s: %s" % s |
991 print "Failed %s: %s" % s |
984 _checkhglib("Tested") |
992 _checkhglib("Tested") |
985 print "# Ran %d tests, %d skipped, %d failed." % ( |
993 print "# Ran %d tests, %d skipped, %d failed." % ( |
986 len(passes) + len(fails), len(skips) + len(ignores), len(fails)) |
994 tested, skipped + ignored, failed) |
987 |
995 |
988 if options.anycoverage: |
996 if options.anycoverage: |
989 outputcoverage(options) |
997 outputcoverage(options) |
990 except KeyboardInterrupt: |
998 except KeyboardInterrupt: |
991 failed = True |
999 failed = True |
992 print "\ninterrupted!" |
1000 print "\ninterrupted!" |
993 |
1001 |
994 if fails: |
1002 if failed: |
995 sys.exit(1) |
1003 sys.exit(1) |
996 |
1004 |
997 def main(): |
1005 def main(): |
998 (options, args) = parseargs() |
1006 (options, args) = parseargs() |
999 if not options.child: |
1007 if not options.child: |