# HG changeset patch # User Matt Mackall # Date 1303681331 18000 # Node ID 17e4691cc4917ae8ace2633e355cf30dd5087968 # Parent b8ae2e290420666e946b20d0280c3f2912fc2645 run-tests: add locking on results struct [ original upstream message ] diff -r b8ae2e290420 -r 17e4691cc491 tests/run-tests.py --- a/tests/run-tests.py Sun Apr 24 23:33:48 2011 +0200 +++ b/tests/run-tests.py Sun Apr 24 16:42:11 2011 -0500 @@ -53,6 +53,7 @@ import tempfile import time import re +import threading closefds = os.name == 'posix' def Popen4(cmd, bufsize=-1): @@ -633,17 +634,24 @@ output = re.sub(s, r, output) return ret, splitnewlines(output) -def runone(options, test, results): +def runone(options, test): '''tristate output: None -> skipped True -> passed False -> failed''' + global results, resultslock + testpath = os.path.join(TESTDIR, test) + def result(l, e): + resultslock.acquire() + results[l].append(e) + resultslock.release() + def skip(msg): if not options.verbose: - results['s'].append((test, msg)) + result('s', (test, msg)) else: print "\nSkipping %s: %s" % (testpath, msg) return None @@ -661,13 +669,13 @@ else: rename(testpath + ".err", testpath + ".out") return - results['f'].append((test, msg)) + result('f', (test, msg)) def success(): - results['p'].append(test) + result('p', test) def ignore(msg): - results['i'].append((test, msg)) + result('i', (test, msg)) if (test.startswith("test-") and '~' not in test and ('.' not in test or test.endswith('.py') or @@ -681,7 +689,7 @@ if options.blacklist: filename = options.blacklist.get(test) if filename is not None: - skipped.append((test, "blacklisted (%s)" % filename)) + skip("blacklisted") return None if options.retest and not os.path.exists(test + ".err"): @@ -935,9 +943,12 @@ outputcoverage(options) sys.exit(failures != 0) +results = dict(p=[], f=[], s=[], i=[]) +resultslock = threading.Lock() + def runqueue(options, tests, results): for test in tests: - ret = runone(options, test, results) + ret = runone(options, test) if options.first and ret is not None and not ret: break @@ -946,8 +957,6 @@ DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') - results = dict(p=[], f=[], s=[], i=[]) - try: if INST: installhg(options)