summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2013-07-19 17:08:08 +0000
committerNico Rieck <nico.rieck@gmail.com>2013-07-19 17:08:08 +0000
commitb21ebec2c441a759731a100059367b8ab05c940a (patch)
tree994ec926ef72b025dfd3dce6e26c8a11c2b4df9f
parent4652d893bc8c7fc75d154ba98b308ddfe3e79f2c (diff)
downloadbcm5719-llvm-b21ebec2c441a759731a100059367b8ab05c940a.tar.gz
bcm5719-llvm-b21ebec2c441a759731a100059367b8ab05c940a.zip
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. llvm-svn: 186695
-rwxr-xr-xllvm/utils/lit/lit/main.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index de97a8e1aaf..74d5d62628d 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/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()
OpenPOWER on IntegriCloud