diff options
author | Nico Rieck <nico.rieck@gmail.com> | 2013-07-19 17:08:08 +0000 |
---|---|---|
committer | Nico Rieck <nico.rieck@gmail.com> | 2013-07-19 17:08:08 +0000 |
commit | ba460864440b4dd192bd2809f913babe0cf07031 (patch) | |
tree | 55228c7d4655c97516f870579ee81f30f2450fe0 /utils/lit | |
parent | 55dcefbc4006204c0d2816d5a7c921517c53383c (diff) | |
download | external_llvm-ba460864440b4dd192bd2809f913babe0cf07031.zip external_llvm-ba460864440b4dd192bd2809f913babe0cf07031.tar.gz external_llvm-ba460864440b4dd192bd2809f913babe0cf07031.tar.bz2 |
lit: Support cancellation on Windows
The current machinery using KeyboardInterrupt for canceling doesn't work
with multiple threads on Windows as it just cancels the currently run tests
but the runners continue.
We install a handler for Ctrl-C which stops the provider from providing any
more tests to the runners. Together with aborting all currently running
tests, this brings lit to a halt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rwxr-xr-x | utils/lit/lit/main.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py index de97a8e..74d5d62 100755 --- a/utils/lit/lit/main.py +++ b/utils/lit/lit/main.py @@ -76,6 +76,12 @@ class TestProvider: self.iter = iter(tests) self.lock = threading.Lock() self.startTime = time.time() + self.canceled = False + + def cancel(self): + self.lock.acquire() + self.canceled = True + self.lock.release() def get(self): # Check if we have run out of time. @@ -85,6 +91,10 @@ class TestProvider: # Otherwise take the next test. self.lock.acquire() + if self.canceled: + self.lock.release() + return None + try: item = self.iter.next() except StopIteration: @@ -346,6 +356,17 @@ def main(builtinParameters = {}): startTime = time.time() display = TestingProgressDisplay(opts, len(tests), progressBar) provider = TestProvider(tests, opts.maxTime) + + try: + import win32api + except ImportError: + pass + else: + def console_ctrl_handler(type): + provider.cancel() + return True + win32api.SetConsoleCtrlHandler(console_ctrl_handler, True) + runTests(opts.numThreads, litConfig, provider, display) display.finish() |