diff --git a/presubmit_support.py b/presubmit_support.py index d9ae4cae9..4684ee773 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1738,7 +1738,7 @@ def DoPresubmitChecks(change, results += executer.ExecPresubmitScript(presubmit_script, filename) else: skipped_count += 1 - + results += thread_pool.RunAsync() messages = {} @@ -1754,11 +1754,15 @@ def DoPresubmitChecks(change, else: messages.setdefault('Messages', []).append(result) - for name, items in messages.items(): - sys.stdout.write('** Presubmit %s **\n' % name) - for item in items: - item.handle() - sys.stdout.write('\n') + # Print the different message types in a consistent order. ERRORS go last + # so that they will be most visible in the local-presubmit output. + for name in ['Messages', 'Warnings', 'ERRORS']: + if name in messages: + items = messages[name] + sys.stdout.write('** Presubmit %s **\n' % name) + for item in items: + item.handle() + sys.stdout.write('\n') total_time = time_time() - start_time if total_time > 1.0: @@ -1774,6 +1778,8 @@ def DoPresubmitChecks(change, 'Are you sure you wish to continue? (y/N): ') else: sys.stdout.write('\n') + else: + sys.stdout.write('There were %s presubmit errors.\n' % python_version) if json_output: # Write the presubmit results to json output diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 4f313c758..91c9faa7d 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -904,9 +904,11 @@ def CheckChangeOnCommit(input_api, output_api): RUNNING_PY_CHECKS_TEXT + 'Warning, no PRESUBMIT.py found.\n' 'Running default presubmit script.\n' '** Presubmit ERRORS **\n!!\n\n' + 'There were Python %d presubmit errors.\n' 'Was the presubmit check useful? If not, run "git cl presubmit -v"\n' 'to figure out which PRESUBMIT.py was run, then run git blame\n' - 'on the file to figure out who to ask for help.\n') + 'on the file to figure out who to ask for help.\n' % + sys.version_info.major) self.assertEqual(sys.stdout.getvalue(), text) def ExampleChange(self, extra_lines=None):