comparison tests/run-tests.py @ 14002:a738c30d4b18

run-tests: add a lock for console I/O
author Matt Mackall <mpm@selenic.com>
date Sun, 24 Apr 2011 16:46:37 -0500
parents 9c4da6ab4e5a
children ba734ff5cadd
comparison
equal deleted inserted replaced
14001:9c4da6ab4e5a 14002:a738c30d4b18
652 '''tristate output: 652 '''tristate output:
653 None -> skipped 653 None -> skipped
654 True -> passed 654 True -> passed
655 False -> failed''' 655 False -> failed'''
656 656
657 global results, resultslock 657 global results, resultslock, iolock
658 658
659 testpath = os.path.join(TESTDIR, test) 659 testpath = os.path.join(TESTDIR, test)
660 660
661 def result(l, e): 661 def result(l, e):
662 resultslock.acquire() 662 resultslock.acquire()
823 if ret: 823 if ret:
824 fail("output changed and returned error code %d" % ret, ret) 824 fail("output changed and returned error code %d" % ret, ret)
825 else: 825 else:
826 fail("output changed", ret) 826 fail("output changed", ret)
827 if ret != 'timeout' and not options.nodiff: 827 if ret != 'timeout' and not options.nodiff:
828 iolock.acquire()
828 if options.view: 829 if options.view:
829 os.system("%s %s %s" % (options.view, ref, err)) 830 os.system("%s %s %s" % (options.view, ref, err))
830 else: 831 else:
831 showdiff(refout, out, ref, err) 832 showdiff(refout, out, ref, err)
833 iolock.release()
832 ret = 1 834 ret = 1
833 elif ret: 835 elif ret:
834 mark = '!' 836 mark = '!'
835 fail("returned error code %d" % ret, ret) 837 fail("returned error code %d" % ret, ret)
836 838
837 if not options.verbose: 839 if not options.verbose:
840 iolock.acquire()
838 sys.stdout.write(mark) 841 sys.stdout.write(mark)
839 sys.stdout.flush() 842 sys.stdout.flush()
843 iolock.release()
840 844
841 killdaemons() 845 killdaemons()
842 846
843 os.chdir(TESTDIR) 847 os.chdir(TESTDIR)
844 if not options.keep_tmpdir: 848 if not options.keep_tmpdir:
952 outputcoverage(options) 956 outputcoverage(options)
953 sys.exit(failures != 0) 957 sys.exit(failures != 0)
954 958
955 results = dict(p=[], f=[], s=[], i=[]) 959 results = dict(p=[], f=[], s=[], i=[])
956 resultslock = threading.Lock() 960 resultslock = threading.Lock()
961 iolock = threading.Lock()
957 962
958 def runqueue(options, tests, results): 963 def runqueue(options, tests, results):
959 for test in tests: 964 for test in tests:
960 ret = runone(options, test) 965 ret = runone(options, test)
961 if options.first and ret is not None and not ret: 966 if options.first and ret is not None and not ret: