[stem/master] Note command to just re-run test failures

commit 6c15247fbfd991090f91d0c4f28f36d0e31b4b43 Author: Damian Johnson <atagar@torproject.org> Date: Thu Jan 8 09:45:46 2015 -0800 Note command to just re-run test failures When our tests fail include the commands to just re-run those tests. Neat idea from Nick on... https://trac.torproject.org/projects/tor/ticket/14113 --- run_tests.py | 15 ++++++++++----- test/output.py | 9 +++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/run_tests.py b/run_tests.py index d157276..c0fa4be 100755 --- a/run_tests.py +++ b/run_tests.py @@ -307,13 +307,18 @@ def main(): runtime_label = '(%i seconds)' % (time.time() - start_time) if error_tracker.has_errors_occured(): - if args.quiet: - println('', STDERR) # extra newline - println('TESTING FAILED %s' % runtime_label, ERROR, STDERR) for line in error_tracker: println(' %s' % line, ERROR, STDERR) + + error_modules = error_tracker.get_modules() + + if len(error_modules) < 10 and not args.specific_test: + println('\nYou can re-run just these tests with:\n', ERROR, STDERR) + + for module in error_modules: + println(' %s --test %s' % (' '.join(sys.argv), module), ERROR, STDERR) else: if skipped_tests > 0: println('%i TESTS WERE SKIPPED' % skipped_tests, STATUS) @@ -373,7 +378,7 @@ def _get_args(argv): args['run_targets'] = run_targets args['attribute_targets'] = attribute_targets - elif opt in ('-l', '--test'): + elif opt in ('-t', '--test'): args['specific_test'] = arg elif opt in ('-l', '--log'): arg = arg.upper() @@ -451,7 +456,7 @@ def _run_test(args, test_class, output_filters, logging_buffer): if args.quiet: println(label, STATUS, NO_NL, STDERR) println(' failed (%0.2fs)' % (time.time() - start_time), ERROR, STDERR) - println(test.output.apply_filters(test_results.getvalue(), *output_filters), NO_NL, STDERR) + println(test.output.apply_filters(test_results.getvalue(), *output_filters), STDERR) else: println(' failed (%0.2fs)' % (time.time() - start_time), ERROR) println(test.output.apply_filters(test_results.getvalue(), *output_filters), NO_NL) diff --git a/test/output.py b/test/output.py index f338753..e88d3de 100644 --- a/test/output.py +++ b/test/output.py @@ -196,6 +196,7 @@ class ErrorTracker(object): def __init__(self): self._errors = [] + self._error_modules = set() self._category = None self._error_noted = False @@ -232,10 +233,18 @@ class ErrorTracker(object): else: self._errors.append(line_content) + module_match = re.match('.*\((test\.\S+)\.\S+\).*', line_content) + + if module_match: + self._error_modules.add(module_match.group(1)) + return line_content return _error_tracker + def get_modules(self): + return self._error_modules + def __iter__(self): for error_line in self._errors: yield error_line
participants (1)
-
atagar@torproject.org