mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[lit] Remove redundancy from names and comments
llvm-svn: 375456
This commit is contained in:
parent
4f72d7419e
commit
2cc38e997a
@ -27,7 +27,7 @@ class LitTestCase(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
# Run the test.
|
||||
result = lit.worker._execute_test(self._test, self._lit_config)
|
||||
result = lit.worker._execute(self._test, self._lit_config)
|
||||
|
||||
# Adapt the result to unittest.
|
||||
if result.code is lit.Test.UNRESOLVED:
|
||||
|
@ -66,14 +66,7 @@ class Run(object):
|
||||
|
||||
return end - start
|
||||
|
||||
def _consume_test_result(self, test, result):
|
||||
"""Test completion callback for lit.worker.run_one_test
|
||||
|
||||
Updates the test result status in the parent process. Each task in the
|
||||
pool returns the test index and the result, and we use the index to look
|
||||
up the original test object. Also updates the progress bar as tasks
|
||||
complete.
|
||||
"""
|
||||
def _process_result(self, test, result):
|
||||
# Don't add any more test results after we've hit the maximum failure
|
||||
# count. Otherwise we're racing with the main thread, which is going
|
||||
# to terminate the process pool soon.
|
||||
@ -100,8 +93,8 @@ class SerialRun(Run):
|
||||
def _execute(self, deadline):
|
||||
# TODO(yln): ignores deadline
|
||||
for test in self.tests:
|
||||
result = lit.worker._execute_test(test, self.lit_config)
|
||||
self._consume_test_result(test, result)
|
||||
result = lit.worker._execute(test, self.lit_config)
|
||||
self._process_result(test, result)
|
||||
if self.hit_max_failures:
|
||||
break
|
||||
|
||||
@ -121,7 +114,7 @@ class ParallelRun(Run):
|
||||
# interrupts the workers before we make it into our task callback, they
|
||||
# will each raise a KeyboardInterrupt exception and print to stderr at
|
||||
# the same time.
|
||||
pool = multiprocessing.Pool(self.workers, lit.worker.initializer,
|
||||
pool = multiprocessing.Pool(self.workers, lit.worker.initialize,
|
||||
(self.lit_config, semaphores))
|
||||
|
||||
# Install a console-control signal handler on Windows.
|
||||
@ -135,10 +128,10 @@ class ParallelRun(Run):
|
||||
lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
|
||||
|
||||
try:
|
||||
async_results = [pool.apply_async(lit.worker.run_one_test,
|
||||
args=(test,),
|
||||
callback=lambda r,t=test: self._consume_test_result(t, r))
|
||||
for test in self.tests]
|
||||
async_results = [
|
||||
pool.apply_async(lit.worker.execute, args=[test],
|
||||
callback=lambda r, t=test: self._process_result(t, r))
|
||||
for test in self.tests]
|
||||
pool.close()
|
||||
|
||||
# Wait for all results to come in. The callback that runs in the
|
||||
|
@ -1,5 +1,10 @@
|
||||
# The functions in this module are meant to run on a separate worker process.
|
||||
# Exception: in single process mode _execute_test is called directly.
|
||||
"""
|
||||
The functions in this module are meant to run on a separate worker process.
|
||||
Exception: in single process mode _execute is called directly.
|
||||
|
||||
For efficiency, we copy all data needed to execute all tests into each worker
|
||||
and store it in global variables. This reduces the cost of each task.
|
||||
"""
|
||||
import time
|
||||
import traceback
|
||||
|
||||
@ -9,35 +14,32 @@ import lit.util
|
||||
_lit_config = None
|
||||
_parallelism_semaphores = None
|
||||
|
||||
def initializer(lit_config, parallelism_semaphores):
|
||||
"""Copy expensive repeated data into worker processes"""
|
||||
def initialize(lit_config, parallelism_semaphores):
|
||||
"""Copy data shared by all test executions into worker processes"""
|
||||
global _lit_config
|
||||
global _parallelism_semaphores
|
||||
_lit_config = lit_config
|
||||
_parallelism_semaphores = parallelism_semaphores
|
||||
|
||||
def run_one_test(test):
|
||||
def execute(test):
|
||||
"""Run one test in a multiprocessing.Pool
|
||||
|
||||
Side effects in this function and functions it calls are not visible in the
|
||||
main lit process.
|
||||
|
||||
Arguments and results of this function are pickled, so they should be cheap
|
||||
to copy. For efficiency, we copy all data needed to execute all tests into
|
||||
each worker and store it in global variables. This reduces the cost of each
|
||||
task.
|
||||
to copy.
|
||||
"""
|
||||
try:
|
||||
return _execute_test_in_parallelism_group(test, _lit_config,
|
||||
_parallelism_semaphores)
|
||||
return _execute_in_parallelism_group(test, _lit_config,
|
||||
_parallelism_semaphores)
|
||||
except KeyboardInterrupt:
|
||||
# If a worker process gets an interrupt, abort it immediately.
|
||||
lit.util.abort_now()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
def _execute_test_in_parallelism_group(test, lit_config, parallelism_semaphores):
|
||||
"""Execute one test inside the appropriate parallelism group"""
|
||||
def _execute_in_parallelism_group(test, lit_config, parallelism_semaphores):
|
||||
pg = test.config.parallelism_group
|
||||
if callable(pg):
|
||||
pg = pg(test)
|
||||
@ -46,14 +48,14 @@ def _execute_test_in_parallelism_group(test, lit_config, parallelism_semaphores)
|
||||
semaphore = parallelism_semaphores[pg]
|
||||
try:
|
||||
semaphore.acquire()
|
||||
return _execute_test(test, lit_config)
|
||||
return _execute(test, lit_config)
|
||||
finally:
|
||||
semaphore.release()
|
||||
else:
|
||||
return _execute_test(test, lit_config)
|
||||
return _execute(test, lit_config)
|
||||
|
||||
|
||||
def _execute_test(test, lit_config):
|
||||
def _execute(test, lit_config):
|
||||
"""Execute one test"""
|
||||
start = time.time()
|
||||
result = _execute_test_handle_errors(test, lit_config)
|
||||
|
Loading…
Reference in New Issue
Block a user