run-tests: add a lock for console I/O stable
authorMatt Mackall <mpm@selenic.com>
Sun, 24 Apr 2011 16:46:37 -0500
branchstable
changeset 914 3c57e9963070
parent 913 ee01b53f9ac9
child 915 5660a21567b7
run-tests: add a lock for console I/O [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Sun Apr 24 16:42:15 2011 -0500
+++ b/tests/run-tests.py	Sun Apr 24 16:46:37 2011 -0500
@@ -654,7 +654,7 @@
     True -> passed
     False -> failed'''
 
-    global results, resultslock
+    global results, resultslock, iolock
 
     testpath = os.path.join(TESTDIR, test)
 
@@ -825,18 +825,22 @@
         else:
             fail("output changed", ret)
         if ret != 'timeout' and not options.nodiff:
+            iolock.acquire()
             if options.view:
                 os.system("%s %s %s" % (options.view, ref, err))
             else:
                 showdiff(refout, out, ref, err)
+            iolock.release()
         ret = 1
     elif ret:
         mark = '!'
         fail("returned error code %d" % ret, ret)
 
     if not options.verbose:
+        iolock.acquire()
         sys.stdout.write(mark)
         sys.stdout.flush()
+        iolock.release()
 
     killdaemons()
 
@@ -954,6 +958,7 @@
 
 results = dict(p=[], f=[], s=[], i=[])
 resultslock = threading.Lock()
+iolock = threading.Lock()
 
 def runqueue(options, tests, results):
     for test in tests: