aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-10-21 21:41:59 +0000
committerJulian Lettner <jlettner@apple.com>2019-10-21 21:41:59 +0000
commit4d5ceef545f84faaa50859e845b55f84bac242da (patch)
tree42e371b2dbe1c5ac5e275fdee2f630b5eb4e122a
parentd8ca3c0d57a0db1a34ef78e860e4504593c69347 (diff)
downloadllvm-4d5ceef545f84faaa50859e845b55f84bac242da.tar.gz
[lit] Remove redundancy from names and comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375456 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/lit/lit/LitTestCase.py2
-rw-r--r--utils/lit/lit/run.py23
-rw-r--r--utils/lit/lit/worker.py32
3 files changed, 26 insertions, 31 deletions
diff --git a/utils/lit/lit/LitTestCase.py b/utils/lit/lit/LitTestCase.py
index c49831323b1..d8a3fc37c89 100644
--- a/utils/lit/lit/LitTestCase.py
+++ b/utils/lit/lit/LitTestCase.py
@@ -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:
diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py
index 9cf57135cff..a246eaa31e8 100644
--- a/utils/lit/lit/run.py
+++ b/utils/lit/lit/run.py
@@ -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
diff --git a/utils/lit/lit/worker.py b/utils/lit/lit/worker.py
index 5527d97f2d8..02fcc20caaf 100644
--- a/utils/lit/lit/worker.py
+++ b/utils/lit/lit/worker.py
@@ -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)