Skip to content

Commit 4d5ceef

Browse files
committed
[lit] Remove redundancy from names and comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375456 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d8ca3c0 commit 4d5ceef

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

utils/lit/lit/LitTestCase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def shortDescription(self):
2727

2828
def runTest(self):
2929
# Run the test.
30-
result = lit.worker._execute_test(self._test, self._lit_config)
30+
result = lit.worker._execute(self._test, self._lit_config)
3131

3232
# Adapt the result to unittest.
3333
if result.code is lit.Test.UNRESOLVED:

utils/lit/lit/run.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,7 @@ def execute(self):
6666

6767
return end - start
6868

69-
def _consume_test_result(self, test, result):
70-
"""Test completion callback for lit.worker.run_one_test
71-
72-
Updates the test result status in the parent process. Each task in the
73-
pool returns the test index and the result, and we use the index to look
74-
up the original test object. Also updates the progress bar as tasks
75-
complete.
76-
"""
69+
def _process_result(self, test, result):
7770
# Don't add any more test results after we've hit the maximum failure
7871
# count. Otherwise we're racing with the main thread, which is going
7972
# to terminate the process pool soon.
@@ -100,8 +93,8 @@ def __init__(self, tests, lit_config, progress_callback, timeout):
10093
def _execute(self, deadline):
10194
# TODO(yln): ignores deadline
10295
for test in self.tests:
103-
result = lit.worker._execute_test(test, self.lit_config)
104-
self._consume_test_result(test, result)
96+
result = lit.worker._execute(test, self.lit_config)
97+
self._process_result(test, result)
10598
if self.hit_max_failures:
10699
break
107100

@@ -121,7 +114,7 @@ def _execute(self, deadline):
121114
# interrupts the workers before we make it into our task callback, they
122115
# will each raise a KeyboardInterrupt exception and print to stderr at
123116
# the same time.
124-
pool = multiprocessing.Pool(self.workers, lit.worker.initializer,
117+
pool = multiprocessing.Pool(self.workers, lit.worker.initialize,
125118
(self.lit_config, semaphores))
126119

127120
# Install a console-control signal handler on Windows.
@@ -135,10 +128,10 @@ def console_ctrl_handler(type):
135128
lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
136129

137130
try:
138-
async_results = [pool.apply_async(lit.worker.run_one_test,
139-
args=(test,),
140-
callback=lambda r,t=test: self._consume_test_result(t, r))
141-
for test in self.tests]
131+
async_results = [
132+
pool.apply_async(lit.worker.execute, args=[test],
133+
callback=lambda r, t=test: self._process_result(t, r))
134+
for test in self.tests]
142135
pool.close()
143136

144137
# Wait for all results to come in. The callback that runs in the

utils/lit/lit/worker.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# The functions in this module are meant to run on a separate worker process.
2-
# Exception: in single process mode _execute_test is called directly.
1+
"""
2+
The functions in this module are meant to run on a separate worker process.
3+
Exception: in single process mode _execute is called directly.
4+
5+
For efficiency, we copy all data needed to execute all tests into each worker
6+
and store it in global variables. This reduces the cost of each task.
7+
"""
38
import time
49
import traceback
510

@@ -9,35 +14,32 @@
914
_lit_config = None
1015
_parallelism_semaphores = None
1116

12-
def initializer(lit_config, parallelism_semaphores):
13-
"""Copy expensive repeated data into worker processes"""
17+
def initialize(lit_config, parallelism_semaphores):
18+
"""Copy data shared by all test executions into worker processes"""
1419
global _lit_config
1520
global _parallelism_semaphores
1621
_lit_config = lit_config
1722
_parallelism_semaphores = parallelism_semaphores
1823

19-
def run_one_test(test):
24+
def execute(test):
2025
"""Run one test in a multiprocessing.Pool
2126
2227
Side effects in this function and functions it calls are not visible in the
2328
main lit process.
2429
2530
Arguments and results of this function are pickled, so they should be cheap
26-
to copy. For efficiency, we copy all data needed to execute all tests into
27-
each worker and store it in global variables. This reduces the cost of each
28-
task.
31+
to copy.
2932
"""
3033
try:
31-
return _execute_test_in_parallelism_group(test, _lit_config,
32-
_parallelism_semaphores)
34+
return _execute_in_parallelism_group(test, _lit_config,
35+
_parallelism_semaphores)
3336
except KeyboardInterrupt:
3437
# If a worker process gets an interrupt, abort it immediately.
3538
lit.util.abort_now()
3639
except:
3740
traceback.print_exc()
3841

39-
def _execute_test_in_parallelism_group(test, lit_config, parallelism_semaphores):
40-
"""Execute one test inside the appropriate parallelism group"""
42+
def _execute_in_parallelism_group(test, lit_config, parallelism_semaphores):
4143
pg = test.config.parallelism_group
4244
if callable(pg):
4345
pg = pg(test)
@@ -46,14 +48,14 @@ def _execute_test_in_parallelism_group(test, lit_config, parallelism_semaphores)
4648
semaphore = parallelism_semaphores[pg]
4749
try:
4850
semaphore.acquire()
49-
return _execute_test(test, lit_config)
51+
return _execute(test, lit_config)
5052
finally:
5153
semaphore.release()
5254
else:
53-
return _execute_test(test, lit_config)
55+
return _execute(test, lit_config)
5456

5557

56-
def _execute_test(test, lit_config):
58+
def _execute(test, lit_config):
5759
"""Execute one test"""
5860
start = time.time()
5961
result = _execute_test_handle_errors(test, lit_config)

0 commit comments

Comments
 (0)