[llvm] r375456 - [lit] Remove redundancy from names and comments

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 14:42:00 PDT 2019


Author: yln
Date: Mon Oct 21 14:41:59 2019
New Revision: 375456

URL: http://llvm.org/viewvc/llvm-project?rev=375456&view=rev
Log:
[lit] Remove redundancy from names and comments

Modified:
    llvm/trunk/utils/lit/lit/LitTestCase.py
    llvm/trunk/utils/lit/lit/run.py
    llvm/trunk/utils/lit/lit/worker.py

Modified: llvm/trunk/utils/lit/lit/LitTestCase.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/LitTestCase.py?rev=375456&r1=375455&r2=375456&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/LitTestCase.py (original)
+++ llvm/trunk/utils/lit/lit/LitTestCase.py Mon Oct 21 14:41:59 2019
@@ -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:

Modified: llvm/trunk/utils/lit/lit/run.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/run.py?rev=375456&r1=375455&r2=375456&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/run.py (original)
+++ llvm/trunk/utils/lit/lit/run.py Mon Oct 21 14:41:59 2019
@@ -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

Modified: llvm/trunk/utils/lit/lit/worker.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/worker.py?rev=375456&r1=375455&r2=375456&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/worker.py (original)
+++ llvm/trunk/utils/lit/lit/worker.py Mon Oct 21 14:41:59 2019
@@ -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(t
         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)




More information about the llvm-commits mailing list