diff options
author | Daniel Dunbar <daniel@zuster.org> | 2013-08-29 00:54:19 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2013-08-29 00:54:19 +0000 |
commit | df44de6d918255eb51f3d042681e006f33948f80 (patch) | |
tree | 4f60f9c336eb8d61d5810abe5be24d9c7da4e063 /utils | |
parent | 07f0f16bfd58c3e44babae65ccd88b9621d15f48 (diff) | |
download | external_llvm-df44de6d918255eb51f3d042681e006f33948f80.zip external_llvm-df44de6d918255eb51f3d042681e006f33948f80.tar.gz external_llvm-df44de6d918255eb51f3d042681e006f33948f80.tar.bz2 |
[lit] Implement --max-time support by using provider cancel method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/lit/lit/run.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index 2ebce85..617c3b9 100644 --- a/utils/lit/lit/run.py +++ b/utils/lit/lit/run.py @@ -14,11 +14,9 @@ import lit.Test # Test Execution Implementation class TestProvider(object): - def __init__(self, tests, max_time): - self.max_time = max_time + def __init__(self, tests): self.iter = iter(range(len(tests))) self.lock = threading.Lock() - self.start_time = time.time() self.canceled = False def cancel(self): @@ -27,16 +25,13 @@ class TestProvider(object): self.lock.release() def get(self): - # Check if we have run out of time. - if self.max_time is not None: - if time.time() - self.start_time > self.max_time: - return None - - # Otherwise take the next test. + # Check if we are cancelled. self.lock.acquire() if self.canceled: self.lock.release() return None + + # Otherwise take the next test. for item in self.iter: break else: @@ -151,7 +146,7 @@ class Run(object): """ # Create the test provider object. - provider = TestProvider(self.tests, max_time) + provider = TestProvider(self.tests) # Install a console-control signal handler on Windows. if win32api is not None: @@ -160,9 +155,20 @@ class Run(object): return True win32api.SetConsoleCtrlHandler(console_ctrl_handler, True) + # Install a timeout handler, if requested. + if max_time is not None: + def timeout_handler(): + provider.cancel() + timeout_timer = threading.Timer(max_time, timeout_handler) + timeout_timer.start() + # Actually execute the tests. self._execute_tests_with_provider(provider, display, jobs) + # Cancel the timeout handler. + if max_time is not None: + timeout_timer.cancel() + # Update results for any tests which weren't run. for test in self.tests: if test.result is None: |