@@ -11,20 +11,20 @@ class NopSemaphore(object):
11
11
def acquire (self ): pass
12
12
def release (self ): pass
13
13
14
- def create_run (tests , lit_config , workers , progress_callback , max_time ):
14
+ def create_run (tests , lit_config , workers , progress_callback , timeout = None ):
15
15
# TODO(yln) assert workers > 0
16
16
if workers == 1 :
17
- return SerialRun (tests , lit_config , progress_callback , max_time )
18
- return ParallelRun (tests , lit_config , progress_callback , max_time , workers )
17
+ return SerialRun (tests , lit_config , progress_callback , timeout )
18
+ return ParallelRun (tests , lit_config , progress_callback , timeout , workers )
19
19
20
20
class Run (object ):
21
21
"""A concrete, configured testing run."""
22
22
23
- def __init__ (self , tests , lit_config , progress_callback , max_time ):
23
+ def __init__ (self , tests , lit_config , progress_callback , timeout ):
24
24
self .tests = tests
25
25
self .lit_config = lit_config
26
26
self .progress_callback = progress_callback
27
- self .max_time = max_time
27
+ self .timeout = timeout
28
28
29
29
def execute (self ):
30
30
"""
@@ -35,7 +35,7 @@ def execute(self):
35
35
36
36
The progress_callback will be invoked for each completed test.
37
37
38
- If max_time is non-None, it should be a time in seconds after which to
38
+ If timeout is non-None, it should be a time in seconds after which to
39
39
stop executing tests.
40
40
41
41
Returns the elapsed testing time.
@@ -51,7 +51,8 @@ def execute(self):
51
51
self .hit_max_failures = False
52
52
53
53
start = time .time ()
54
- self ._execute ()
54
+ deadline = (start + self .timeout ) if self .timeout else float ('inf' )
55
+ self ._execute (deadline )
55
56
end = time .time ()
56
57
57
58
# Mark any tests that weren't run as UNRESOLVED.
@@ -91,25 +92,23 @@ def _consume_test_result(self, pool_result):
91
92
self .hit_max_failures = True
92
93
93
94
class SerialRun (Run ):
94
- def __init__ (self , tests , lit_config , progress_callback , max_time ):
95
- super (SerialRun , self ).__init__ (tests , lit_config , progress_callback , max_time )
95
+ def __init__ (self , tests , lit_config , progress_callback , timeout ):
96
+ super (SerialRun , self ).__init__ (tests , lit_config , progress_callback , timeout )
96
97
97
- def _execute (self ):
98
- # TODO(yln): ignores max_time
98
+ def _execute (self , deadline ):
99
+ # TODO(yln): ignores deadline
99
100
for test_index , test in enumerate (self .tests ):
100
101
lit .worker ._execute_test (test , self .lit_config )
101
102
self ._consume_test_result ((test_index , test ))
102
103
if self .hit_max_failures :
103
104
break
104
105
105
106
class ParallelRun (Run ):
106
- def __init__ (self , tests , lit_config , progress_callback , max_time , workers ):
107
- super (ParallelRun , self ).__init__ (tests , lit_config , progress_callback , max_time )
107
+ def __init__ (self , tests , lit_config , progress_callback , timeout , workers ):
108
+ super (ParallelRun , self ).__init__ (tests , lit_config , progress_callback , timeout )
108
109
self .workers = workers
109
110
110
- def _execute (self ):
111
- deadline = (time .time () + self .max_time ) if self .max_time else float ('inf' )
112
-
111
+ def _execute (self , deadline ):
113
112
semaphores = {
114
113
k : NopSemaphore () if v is None else
115
114
multiprocessing .BoundedSemaphore (v ) for k , v in
0 commit comments