##// 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 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
@@ -643,7 +643,7 b' def runone(options, test, skips, passes,'
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
@@ -660,7 +660,13 b' def runone(options, test, skips, passes,'
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
@@ -678,7 +684,7 b' def runone(options, test, skips, passes,'
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:
@@ -689,7 +695,7 b' def runone(options, test, skips, passes,'
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)
@@ -756,7 +762,7 b' def runone(options, test, skips, passes,'
756
762
757 mark = '.'
763 mark = '.'
758 if ret == 0:
764 if ret == 0:
759 passes.append(test)
765 success()
760
766
761 skipped = (ret == SKIPPED_STATUS)
767 skipped = (ret == SKIPPED_STATUS)
762
768
@@ -933,6 +939,8 b' def runtests(options, tests):'
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)
@@ -957,33 +965,33 b' def runtests(options, 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
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 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)
@@ -991,7 +999,7 b' def runtests(options, tests):'
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():
General Comments 0
You need to be logged in to leave comments. Login now