summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit
diff options
context:
space:
mode:
authorJulian Lettner <julian.lettner@gmail.com>2019-02-25 21:25:29 -0800
committerJulian Lettner <julian.lettner@apple.com>2019-11-22 10:57:33 -0800
commit718d68e6ca874fcb8a720790c899fa311f15675a (patch)
tree38d94b47e2bb3439de3ca15688ca95edc947a803 /llvm/utils/lit
parent506144da04b94d7d492ad34f7d3d81e8368677bb (diff)
downloadbcm5719-llvm-718d68e6ca874fcb8a720790c899fa311f15675a.tar.gz
bcm5719-llvm-718d68e6ca874fcb8a720790c899fa311f15675a.zip
[lit] Attempt to print test summary on CTRL+C
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r--llvm/utils/lit/lit/ProgressBar.py9
-rw-r--r--llvm/utils/lit/lit/display.py9
-rwxr-xr-xllvm/utils/lit/lit/main.py22
3 files changed, 20 insertions, 20 deletions
diff --git a/llvm/utils/lit/lit/ProgressBar.py b/llvm/utils/lit/lit/ProgressBar.py
index cefde67a3d0..4f8bd3cc75e 100644
--- a/llvm/utils/lit/lit/ProgressBar.py
+++ b/llvm/utils/lit/lit/ProgressBar.py
@@ -201,8 +201,8 @@ class SimpleProgressBar:
sys.stdout.flush()
self.atIndex = next
- def clear(self):
- if self.atIndex is not None:
+ def clear(self, interrupted):
+ if self.atIndex is not None and not interrupted:
sys.stdout.write('\n')
sys.stdout.flush()
self.atIndex = None
@@ -275,11 +275,14 @@ class ProgressBar:
if not self.term.XN:
sys.stdout.flush()
- def clear(self):
+ def clear(self, interrupted):
if not self.cleared:
sys.stdout.write(self.BOL + self.term.CLEAR_EOL +
self.term.UP + self.term.CLEAR_EOL +
self.term.UP + self.term.CLEAR_EOL)
+ if interrupted: # ^C creates extra line. Gobble it up!
+ sys.stdout.write(self.term.UP + self.term.CLEAR_EOL)
+ sys.stdout.write('^C')
sys.stdout.flush()
self.cleared = 1
diff --git a/llvm/utils/lit/lit/display.py b/llvm/utils/lit/lit/display.py
index 05b752a90fd..c986b341512 100644
--- a/llvm/utils/lit/lit/display.py
+++ b/llvm/utils/lit/lit/display.py
@@ -24,7 +24,7 @@ def create_display(opts, tests, total_tests, workers):
class NopDisplay(object):
def print_header(self): pass
def update(self, test): pass
- def clear(self): pass
+ def clear(self, interrupted): pass
class Display(object):
@@ -49,7 +49,7 @@ class Display(object):
(not self.opts.quiet and not self.opts.succinct)
if show_result:
if self.progress_bar:
- self.progress_bar.clear()
+ self.progress_bar.clear(interrupted=False)
self.print_result(test)
if self.progress_bar:
@@ -58,10 +58,9 @@ class Display(object):
percent = float(self.completed) / self.tests
self.progress_bar.update(percent, test.getFullName())
- def clear(self):
+ def clear(self, interrupted):
if self.progress_bar:
- self.progress_bar.clear()
- sys.stdout.write('\n')
+ self.progress_bar.clear(interrupted)
def print_result(self, test):
# Show the test result line.
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 0eb95b9c2ab..e8d539a17c4 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -97,7 +97,9 @@ def main(builtin_params = {}):
run_tests(tests, litConfig, opts, numTotalTests)
elapsed = time.time() - start
- print_summary(tests, elapsed, opts)
+ executed_tests = [t for t in tests if t.result]
+
+ print_summary(executed_tests, elapsed, opts)
if opts.output_path:
write_test_results(tests, litConfig, elapsed, opts.output_path)
@@ -111,7 +113,7 @@ def main(builtin_params = {}):
if litConfig.numWarnings:
sys.stderr.write('\n%d warning(s) in tests.\n' % litConfig.numWarnings)
- has_failure = any(t.isFailure() for t in tests)
+ has_failure = any(t.isFailure() for t in executed_tests)
if has_failure:
sys.exit(1)
@@ -203,16 +205,10 @@ def run_tests(tests, litConfig, opts, numTotalTests):
display.print_header()
try:
execute_in_tmp_dir(run, litConfig)
+ display.clear(interrupted=False)
except KeyboardInterrupt:
- #TODO(yln): should we attempt to cleanup the progress bar here?
- sys.exit(2)
- # TODO(yln): display.finish_interrupted(), which shows the most recently started test
- # TODO(yln): change display to update when test starts, not when test completes
- # Ensure everything still works with SimpleProgressBar as well
- # finally:
- # display.clear()
-
- display.clear()
+ display.clear(interrupted=True)
+ print(' [interrupted by user]')
def execute_in_tmp_dir(run, litConfig):
# Create a temp directory inside the normal temp directory so that we can
@@ -247,7 +243,7 @@ def execute_in_tmp_dir(run, litConfig):
def print_summary(tests, elapsed, opts):
if not opts.quiet:
- print('Testing Time: %.2fs' % elapsed)
+ print('\nTesting Time: %.2fs' % elapsed)
byCode = {}
for test in tests:
@@ -296,6 +292,7 @@ def print_summary(tests, elapsed, opts):
print(' %s: %d' % (name,N))
def write_test_results(tests, lit_config, elapsed, output_path):
+ # TODO(yln): audit: unexecuted tests
# Construct the data we will write.
data = {}
# Encode the current lit version as a schema version.
@@ -350,6 +347,7 @@ def write_test_results(tests, lit_config, elapsed, output_path):
f.close()
def write_test_results_xunit(tests, opts):
+ # TODO(yln): audit: unexecuted tests
from xml.sax.saxutils import quoteattr
# Collect the tests, indexed by test suite
by_suite = {}
OpenPOWER on IntegriCloud