##// END OF EJS Templates
run-tests: use a results dict
Matt Mackall -
r13994:f31a5b7f default
parent child Browse files
Show More
@@ -633,7 +633,7 b' def run(cmd, options, replacements):'
633 633 output = re.sub(s, r, output)
634 634 return ret, splitnewlines(output)
635 635
636 def runone(options, test, skips, passes, fails, ignores):
636 def runone(options, test, results):
637 637 '''tristate output:
638 638 None -> skipped
639 639 True -> passed
@@ -643,7 +643,7 b' def runone(options, test, skips, passes,'
643 643
644 644 def skip(msg):
645 645 if not options.verbose:
646 skips.append((test, msg))
646 results['s'].append((test, msg))
647 647 else:
648 648 print "\nSkipping %s: %s" % (testpath, msg)
649 649 return None
@@ -660,7 +660,13 b' def runone(options, test, skips, passes,'
660 660 else:
661 661 rename(test + ".err", test + ".out")
662 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 671 if (test.startswith("test-") and '~' not in test and
666 672 ('.' not in test or test.endswith('.py') or
@@ -678,7 +684,7 b' def runone(options, test, skips, passes,'
678 684 return None
679 685
680 686 if options.retest and not os.path.exists(test + ".err"):
681 ignores.append((test, "not retesting"))
687 ignore("not retesting")
682 688 return None
683 689
684 690 if options.keywords:
@@ -689,7 +695,7 b' def runone(options, test, skips, passes,'
689 695 if k in t:
690 696 break
691 697 else:
692 ignores.append((test, "doesn't match keyword"))
698 ignore("doesn't match keyword")
693 699 return None
694 700
695 701 vlog("# Test", test)
@@ -756,7 +762,7 b' def runone(options, test, skips, passes,'
756 762
757 763 mark = '.'
758 764 if ret == 0:
759 passes.append(test)
765 success()
760 766
761 767 skipped = (ret == SKIPPED_STATUS)
762 768
@@ -933,6 +939,8 b' def runtests(options, tests):'
933 939 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids')
934 940 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc')
935 941
942 results = dict(p=[], f=[], s=[], i=[])
943
936 944 try:
937 945 if INST:
938 946 installhg(options)
@@ -957,33 +965,33 b' def runtests(options, tests):'
957 965 print "running all tests"
958 966 tests = orig
959 967
960 passes = []
961 skips = []
962 fails = []
963 ignores = []
964
965 968 for test in tests:
966 ret = runone(options, test, skips, passes, fails, ignores)
969 ret = runone(options, test, results)
967 970 if options.first and ret is not None and not ret:
968 971 break
969 972
973 failed = len(results['f'])
974 tested = len(results['p']) + failed
975 skipped = len(results['s'])
976 ignored = len(results['i'])
977
970 978 if options.child:
971 979 fp = os.fdopen(options.child, 'w')
972 980 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
973 for s in skips:
981 for s in results['s']:
974 982 fp.write("%s %s\n" % s)
975 for s in fails:
983 for s in results['f']:
976 984 fp.write("%s %s\n" % s)
977 985 fp.close()
978 986 else:
979 987 print
980 for s in skips:
988 for s in results['s']:
981 989 print "Skipped %s: %s" % s
982 for s in fails:
990 for s in results['f']:
983 991 print "Failed %s: %s" % s
984 992 _checkhglib("Tested")
985 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 996 if options.anycoverage:
989 997 outputcoverage(options)
@@ -991,7 +999,7 b' def runtests(options, tests):'
991 999 failed = True
992 1000 print "\ninterrupted!"
993 1001
994 if fails:
1002 if failed:
995 1003 sys.exit(1)
996 1004
997 1005 def main():
General Comments 0
You need to be logged in to leave comments. Login now