From: Julian Lettner Date: Thu, 17 Oct 2019 16:01:21 +0000 (+0000) Subject: [lit] Move computation of deadline up into base class X-Git-Tag: llvmorg-11-init~6263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a660dc590a5e8dafa1ba6ed56447ede151d17bd9;p=platform%2Fupstream%2Fllvm.git [lit] Move computation of deadline up into base class llvm-svn: 375130 --- diff --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py index fb53817..d758f7a 100644 --- a/llvm/utils/lit/lit/run.py +++ b/llvm/utils/lit/lit/run.py @@ -11,20 +11,20 @@ class NopSemaphore(object): def acquire(self): pass def release(self): pass -def create_run(tests, lit_config, workers, progress_callback, max_time): +def create_run(tests, lit_config, workers, progress_callback, timeout=None): # TODO(yln) assert workers > 0 if workers == 1: - return SerialRun(tests, lit_config, progress_callback, max_time) - return ParallelRun(tests, lit_config, progress_callback, max_time, workers) + return SerialRun(tests, lit_config, progress_callback, timeout) + return ParallelRun(tests, lit_config, progress_callback, timeout, workers) class Run(object): """A concrete, configured testing run.""" - def __init__(self, tests, lit_config, progress_callback, max_time): + def __init__(self, tests, lit_config, progress_callback, timeout): self.tests = tests self.lit_config = lit_config self.progress_callback = progress_callback - self.max_time = max_time + self.timeout = timeout def execute(self): """ @@ -35,7 +35,7 @@ class Run(object): The progress_callback will be invoked for each completed test. - If max_time is non-None, it should be a time in seconds after which to + If timeout is non-None, it should be a time in seconds after which to stop executing tests. Returns the elapsed testing time. @@ -51,7 +51,8 @@ class Run(object): self.hit_max_failures = False start = time.time() - self._execute() + deadline = (start + self.timeout) if self.timeout else float('inf') + self._execute(deadline) end = time.time() # Mark any tests that weren't run as UNRESOLVED. @@ -91,11 +92,11 @@ class Run(object): self.hit_max_failures = True class SerialRun(Run): - def __init__(self, tests, lit_config, progress_callback, max_time): - super(SerialRun, self).__init__(tests, lit_config, progress_callback, max_time) + def __init__(self, tests, lit_config, progress_callback, timeout): + super(SerialRun, self).__init__(tests, lit_config, progress_callback, timeout) - def _execute(self): - # TODO(yln): ignores max_time + def _execute(self, deadline): + # TODO(yln): ignores deadline for test_index, test in enumerate(self.tests): lit.worker._execute_test(test, self.lit_config) self._consume_test_result((test_index, test)) @@ -103,13 +104,11 @@ class SerialRun(Run): break class ParallelRun(Run): - def __init__(self, tests, lit_config, progress_callback, max_time, workers): - super(ParallelRun, self).__init__(tests, lit_config, progress_callback, max_time) + def __init__(self, tests, lit_config, progress_callback, timeout, workers): + super(ParallelRun, self).__init__(tests, lit_config, progress_callback, timeout) self.workers = workers - def _execute(self): - deadline = (time.time() + self.max_time) if self.max_time else float('inf') - + def _execute(self, deadline): semaphores = { k: NopSemaphore() if v is None else multiprocessing.BoundedSemaphore(v) for k, v in