@@ -25,7 +25,51 @@ def __init__(self, lit_config, tests):
25
25
multiprocessing .BoundedSemaphore (v )
26
26
for k , v in lit_config .parallelism_groups .items ()}
27
27
28
- def _execute_tests_in_pool (self , workers , max_time ):
28
+ def execute_tests (self , progress_callback , workers , max_time ):
29
+ """
30
+ execute_tests(progress_callback, workers, max_time)
31
+
32
+ Execute the tests in the run using up to the specified number of
33
+ parallel tasks, and inform the caller of each individual result. The
34
+ provided tests should be a subset of the tests available in this run
35
+ object.
36
+
37
+ The progress_callback will be invoked for each completed test.
38
+
39
+ If max_time is non-None, it should be a time in seconds after which to
40
+ stop executing tests.
41
+
42
+ Upon completion, each test in the run will have its result
43
+ computed. Tests which were not actually executed (for any reason) will
44
+ be given an UNRESOLVED result.
45
+ """
46
+ # Don't do anything if we aren't going to run any tests.
47
+ if not self .tests :
48
+ return
49
+
50
+ self .progress_callback = progress_callback
51
+
52
+ self .failure_count = 0
53
+ self .hit_max_failures = False
54
+ if workers == 1 :
55
+ self ._execute_in_serial (max_time )
56
+ else :
57
+ self ._execute_in_parallel (workers , max_time )
58
+
59
+ # Mark any tests that weren't run as UNRESOLVED.
60
+ for test in self .tests :
61
+ if test .result is None :
62
+ test .setResult (lit .Test .Result (lit .Test .UNRESOLVED , '' , 0.0 ))
63
+
64
+ def _execute_in_serial (self , max_time ):
65
+ for test_index , test in enumerate (self .tests ):
66
+ lit .worker ._execute_test (test , self .lit_config )
67
+ self ._consume_test_result ((test_index , test ))
68
+ if self .hit_max_failures :
69
+ break
70
+
71
+ def _execute_in_parallel (self , workers , max_time ):
72
+ assert workers > 1
29
73
# We need to issue many wait calls, so compute the final deadline and
30
74
# subtract time.time() from that as we go along.
31
75
deadline = None
@@ -54,7 +98,7 @@ def console_ctrl_handler(type):
54
98
try :
55
99
async_results = [pool .apply_async (lit .worker .run_one_test ,
56
100
args = (test_index , test ),
57
- callback = self .consume_test_result )
101
+ callback = self ._consume_test_result )
58
102
for test_index , test in enumerate (self .tests )]
59
103
pool .close ()
60
104
@@ -81,47 +125,7 @@ def console_ctrl_handler(type):
81
125
finally :
82
126
pool .join ()
83
127
84
- def execute_tests (self , progress_callback , workers , max_time ):
85
- """
86
- execute_tests(progress_callback, workers, max_time)
87
-
88
- Execute the tests in the run using up to the specified number of
89
- parallel tasks, and inform the caller of each individual result. The
90
- provided tests should be a subset of the tests available in this run
91
- object.
92
-
93
- The progress_callback will be invoked for each completed test.
94
-
95
- If max_time is non-None, it should be a time in seconds after which to
96
- stop executing tests.
97
-
98
- Upon completion, each test in the run will have its result
99
- computed. Tests which were not actually executed (for any reason) will
100
- be given an UNRESOLVED result.
101
- """
102
- # Don't do anything if we aren't going to run any tests.
103
- if not self .tests :
104
- return
105
-
106
- self .progress_callback = progress_callback
107
-
108
- self .failure_count = 0
109
- self .hit_max_failures = False
110
- if workers == 1 :
111
- for test_index , test in enumerate (self .tests ):
112
- lit .worker ._execute_test (test , self .lit_config )
113
- self .consume_test_result ((test_index , test ))
114
- if self .hit_max_failures :
115
- break
116
- else :
117
- self ._execute_tests_in_pool (workers , max_time )
118
-
119
- # Mark any tests that weren't run as UNRESOLVED.
120
- for test in self .tests :
121
- if test .result is None :
122
- test .setResult (lit .Test .Result (lit .Test .UNRESOLVED , '' , 0.0 ))
123
-
124
- def consume_test_result (self , pool_result ):
128
+ def _consume_test_result (self , pool_result ):
125
129
"""Test completion callback for lit.worker.run_one_test
126
130
127
131
Updates the test result status in the parent process. Each task in the
0 commit comments