[llvm] r375263 - [lit] Remove unnecessary tracking of test_index

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 10:31:48 PDT 2019


Author: yln
Date: Fri Oct 18 10:31:48 2019
New Revision: 375263

URL: http://llvm.org/viewvc/llvm-project?rev=375263&view=rev
Log:
[lit] Remove unnecessary tracking of test_index

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

Modified: llvm/trunk/utils/lit/lit/run.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/run.py?rev=375263&r1=375262&r2=375263&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/run.py (original)
+++ llvm/trunk/utils/lit/lit/run.py Fri Oct 18 10:31:48 2019
@@ -65,7 +65,7 @@ class Run(object):
 
         return end - start
 
-    def _consume_test_result(self, pool_result):
+    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
@@ -79,8 +79,6 @@ class Run(object):
         if self.hit_max_failures:
             return
 
-        (test_index, result) = pool_result
-        test = self.tests[test_index]
         # Update the parent process copy of the test. This includes the result,
         # XFAILS, REQUIRES, and UNSUPPORTED statuses.
         test.setResult(result)
@@ -100,9 +98,9 @@ class SerialRun(Run):
 
     def _execute(self, deadline):
         # TODO(yln): ignores deadline
-        for test_index, test in enumerate(self.tests):
+        for test in self.tests:
             result = lit.worker._execute_test(test, self.lit_config)
-            self._consume_test_result((test_index, result))
+            self._consume_test_result(test, result)
             if self.hit_max_failures:
                 break
 
@@ -137,9 +135,9 @@ class ParallelRun(Run):
 
         try:
             async_results = [pool.apply_async(lit.worker.run_one_test,
-                                              args=(test_index, test),
-                                              callback=self._consume_test_result)
-                             for test_index, test in enumerate(self.tests)]
+                                              args=(test,),
+                                              callback=lambda r,t=test: self._consume_test_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=375263&r1=375262&r2=375263&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/worker.py (original)
+++ llvm/trunk/utils/lit/lit/worker.py Fri Oct 18 10:31:48 2019
@@ -16,7 +16,7 @@ def initializer(lit_config, parallelism_
     _lit_config = lit_config
     _parallelism_semaphores = parallelism_semaphores
 
-def run_one_test(test_index, test):
+def run_one_test(test):
     """Run one test in a multiprocessing.Pool
 
     Side effects in this function and functions it calls are not visible in the
@@ -24,16 +24,12 @@ def run_one_test(test_index, test):
 
     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 the worker_* global variables. This reduces the
-    cost of each task.
-
-    Returns an index and a Result, which the parent process uses to update
-    the display.
+    each worker and store it in global variables. This reduces the cost of each
+    task.
     """
     try:
-        result = _execute_test_in_parallelism_group(test, _lit_config,
-                                                    _parallelism_semaphores)
-        return (test_index, result)
+        return _execute_test_in_parallelism_group(test, _lit_config,
+                                                  _parallelism_semaphores)
     except KeyboardInterrupt:
         # If a worker process gets an interrupt, abort it immediately.
         lit.util.abort_now()




More information about the llvm-commits mailing list