Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: presubmit_canned_checks.py

Issue 119252: Add InputApi.is_committing to be able to return a failure or notification, depending on the check. (Closed)
Patch Set: merged to trunk Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 36ccfe9a3a770e1edd20692032df7a6c7f32a8bc..09439fb8833e5dc2d70db3f1796a7fd7dd706bcd 100755
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -125,17 +125,23 @@ def _RunPythonUnitTests_LoadTests(input_api, module_name):
def RunPythonUnitTests(input_api, output_api, unit_tests):
"""Imports the unit_tests modules and run them."""
+ # We don't want to hinder users from uploading incomplete patches.
+ if input_api.is_committing:
+ message_type = output_api.PresubmitError
+ else:
+ message_type = output_api.PresubmitNotifyResult
tests_suite = []
outputs = []
for unit_test in unit_tests:
try:
tests_suite.extend(_RunPythonUnitTests_LoadTests(unit_test))
except ImportError:
- outputs.append(output_api.PresubmitError("Failed to load %s" % unit_test))
+ outputs.append(message_type("Failed to load %s" % unit_test,
+ long_text=input_api.traceback.format_exc()))
results = input_api.unittest.TextTestRunner(verbosity=0).run(
input_api.unittest.TestSuite(tests_suite))
if not results.wasSuccessful():
- outputs.append(output_api.PresubmitError(
+ outputs.append(message_type(
"%d unit tests failed." % (results.failures + results.errors)))
return outputs
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698