comparison tests/run-tests.py @ 17920:4a4173519b63

run-tests: remove resultslock since it serves no useful purpose Each child process has its own copy of the results dict, so all access to the results dict is serial.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 09 Nov 2012 15:09:35 -0800
parents 7e819ea679bd
children 4ac9cf3d810c
comparison
equal deleted inserted replaced
17919:7e819ea679bd 17920:4a4173519b63
752 '''tristate output: 752 '''tristate output:
753 None -> skipped 753 None -> skipped
754 True -> passed 754 True -> passed
755 False -> failed''' 755 False -> failed'''
756 756
757 global results, resultslock, iolock 757 global results, iolock
758 758
759 testpath = os.path.join(TESTDIR, test) 759 testpath = os.path.join(TESTDIR, test)
760
761 def result(l, e):
762 resultslock.acquire()
763 results[l].append(e)
764 resultslock.release()
765 760
766 def skip(msg): 761 def skip(msg):
767 if not options.verbose: 762 if not options.verbose:
768 result('s', (test, msg)) 763 results['s'].append((test, msg))
769 else: 764 else:
770 iolock.acquire() 765 iolock.acquire()
771 print "\nSkipping %s: %s" % (testpath, msg) 766 print "\nSkipping %s: %s" % (testpath, msg)
772 iolock.release() 767 iolock.release()
773 return None 768 return None
786 if answer.lower() in "y yes".split(): 781 if answer.lower() in "y yes".split():
787 if test.endswith(".t"): 782 if test.endswith(".t"):
788 rename(testpath + ".err", testpath) 783 rename(testpath + ".err", testpath)
789 else: 784 else:
790 rename(testpath + ".err", testpath + ".out") 785 rename(testpath + ".err", testpath + ".out")
791 result('p', test) 786 success(test)
792 return 787 return
793 result('f', (test, msg)) 788 results['f'].append((test, msg))
794 789
795 def success(): 790 def success():
796 result('p', test) 791 results['p'].append(test)
797 792
798 def ignore(msg): 793 def ignore(msg):
799 result('i', (test, msg)) 794 results['i'].append((test, msg))
800 795
801 if (os.path.basename(test).startswith("test-") and '~' not in test and 796 if (os.path.basename(test).startswith("test-") and '~' not in test and
802 ('.' not in test or test.endswith('.py') or 797 ('.' not in test or test.endswith('.py') or
803 test.endswith('.bat') or test.endswith('.t'))): 798 test.endswith('.bat') or test.endswith('.t'))):
804 if not os.path.exists(test): 799 if not os.path.exists(test):
1097 if options.anycoverage: 1092 if options.anycoverage:
1098 outputcoverage(options) 1093 outputcoverage(options)
1099 sys.exit(failures != 0) 1094 sys.exit(failures != 0)
1100 1095
1101 results = dict(p=[], f=[], s=[], i=[]) 1096 results = dict(p=[], f=[], s=[], i=[])
1102 resultslock = threading.Lock()
1103 iolock = threading.Lock() 1097 iolock = threading.Lock()
1104 1098
1105 def runqueue(options, tests, results): 1099 def runqueue(options, tests, results):
1106 for test in tests: 1100 for test in tests:
1107 ret = runone(options, test) 1101 ret = runone(options, test)