mirror of https://github.com/tc39/test262.git
Merge pull request #502 from bocoup/runner-race
Avoid Race Conditions in Test Runner
This commit is contained in:
commit
834a28cb95
|
@ -583,6 +583,7 @@ class TestSuite(object):
|
||||||
SkipCaseElement.append(SkipElement)
|
SkipCaseElement.append(SkipElement)
|
||||||
TestSuiteElement.append(SkipCaseElement)
|
TestSuiteElement.append(SkipCaseElement)
|
||||||
|
|
||||||
|
threads = []
|
||||||
if workers_count > 1:
|
if workers_count > 1:
|
||||||
pool_sem = threading.Semaphore(workers_count)
|
pool_sem = threading.Semaphore(workers_count)
|
||||||
log_lock = threading.Lock()
|
log_lock = threading.Lock()
|
||||||
|
@ -605,19 +606,22 @@ class TestSuite(object):
|
||||||
if logname:
|
if logname:
|
||||||
self.WriteLog(result)
|
self.WriteLog(result)
|
||||||
finally:
|
finally:
|
||||||
|
progress.HasRun(result)
|
||||||
|
|
||||||
if workers_count > 1:
|
if workers_count > 1:
|
||||||
log_lock.release()
|
log_lock.release()
|
||||||
|
|
||||||
progress.HasRun(result)
|
|
||||||
if workers_count == 1:
|
if workers_count == 1:
|
||||||
exec_case()
|
exec_case()
|
||||||
else:
|
else:
|
||||||
pool_sem.acquire()
|
pool_sem.acquire()
|
||||||
threading.Thread(target=exec_case).start()
|
thread = threading.Thread(target=exec_case)
|
||||||
|
threads.append(thread)
|
||||||
|
thread.start()
|
||||||
pool_sem.release()
|
pool_sem.release()
|
||||||
|
|
||||||
if workers_count > 1:
|
for thread in threads:
|
||||||
log_lock.acquire()
|
thread.join()
|
||||||
|
|
||||||
if print_summary:
|
if print_summary:
|
||||||
self.PrintSummary(progress, logname)
|
self.PrintSummary(progress, logname)
|
||||||
|
@ -628,9 +632,6 @@ class TestSuite(object):
|
||||||
print "Use --full-summary to see output from failed tests"
|
print "Use --full-summary to see output from failed tests"
|
||||||
print
|
print
|
||||||
|
|
||||||
if workers_count > 1:
|
|
||||||
log_lock.release()
|
|
||||||
|
|
||||||
return progress.failed
|
return progress.failed
|
||||||
|
|
||||||
def WriteLog(self, result):
|
def WriteLog(self, result):
|
||||||
|
|
Loading…
Reference in New Issue