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
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
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):
(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:
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.
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)
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)
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
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:
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.
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 = {}