##// END OF EJS Templates
run-tests: add locking on results struct
Matt Mackall -
r14000:636a6f5a default
parent child Browse files
Show More
@@ -53,6 +53,7 b' import sys'
53 import tempfile
53 import tempfile
54 import time
54 import time
55 import re
55 import re
56 import threading
56
57
57 closefds = os.name == 'posix'
58 closefds = os.name == 'posix'
58 def Popen4(cmd, bufsize=-1):
59 def Popen4(cmd, bufsize=-1):
@@ -633,17 +634,24 b' def run(cmd, options, replacements):'
633 output = re.sub(s, r, output)
634 output = re.sub(s, r, output)
634 return ret, splitnewlines(output)
635 return ret, splitnewlines(output)
635
636
636 def runone(options, test, results):
637 def runone(options, test):
637 '''tristate output:
638 '''tristate output:
638 None -> skipped
639 None -> skipped
639 True -> passed
640 True -> passed
640 False -> failed'''
641 False -> failed'''
641
642
643 global results, resultslock
644
642 testpath = os.path.join(TESTDIR, test)
645 testpath = os.path.join(TESTDIR, test)
643
646
647 def result(l, e):
648 resultslock.acquire()
649 results[l].append(e)
650 resultslock.release()
651
644 def skip(msg):
652 def skip(msg):
645 if not options.verbose:
653 if not options.verbose:
646 results['s'].append((test, msg))
654 result('s', (test, msg))
647 else:
655 else:
648 print "\nSkipping %s: %s" % (testpath, msg)
656 print "\nSkipping %s: %s" % (testpath, msg)
649 return None
657 return None
@@ -661,13 +669,13 b' def runone(options, test, results):'
661 else:
669 else:
662 rename(testpath + ".err", testpath + ".out")
670 rename(testpath + ".err", testpath + ".out")
663 return
671 return
664 results['f'].append((test, msg))
672 result('f', (test, msg))
665
673
666 def success():
674 def success():
667 results['p'].append(test)
675 result('p', test)
668
676
669 def ignore(msg):
677 def ignore(msg):
670 results['i'].append((test, msg))
678 result('i', (test, msg))
671
679
672 if (test.startswith("test-") and '~' not in test and
680 if (test.startswith("test-") and '~' not in test and
673 ('.' not in test or test.endswith('.py') or
681 ('.' not in test or test.endswith('.py') or
@@ -681,7 +689,7 b' def runone(options, test, results):'
681 if options.blacklist:
689 if options.blacklist:
682 filename = options.blacklist.get(test)
690 filename = options.blacklist.get(test)
683 if filename is not None:
691 if filename is not None:
684 skipped.append((test, "blacklisted (%s)" % filename))
692 skip("blacklisted")
685 return None
693 return None
686
694
687 if options.retest and not os.path.exists(test + ".err"):
695 if options.retest and not os.path.exists(test + ".err"):
@@ -935,9 +943,12 b' def runchildren(options, tests):'
935 outputcoverage(options)
943 outputcoverage(options)
936 sys.exit(failures != 0)
944 sys.exit(failures != 0)
937
945
946 results = dict(p=[], f=[], s=[], i=[])
947 resultslock = threading.Lock()
948
938 def runqueue(options, tests, results):
949 def runqueue(options, tests, results):
939 for test in tests:
950 for test in tests:
940 ret = runone(options, test, results)
951 ret = runone(options, test)
941 if options.first and ret is not None and not ret:
952 if options.first and ret is not None and not ret:
942 break
953 break
943
954
@@ -946,8 +957,6 b' def runtests(options, tests):'
946 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids')
957 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids')
947 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc')
958 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc')
948
959
949 results = dict(p=[], f=[], s=[], i=[])
950
951 try:
960 try:
952 if INST:
961 if INST:
953 installhg(options)
962 installhg(options)
General Comments 0
You need to be logged in to leave comments. Login now