Index: tools/binary_size/PRESUBMIT.py |
diff --git a/tools/binary_size/PRESUBMIT.py b/tools/binary_size/PRESUBMIT.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..4341fb6f874b1e584d7ae563370d6680d11d69ef |
--- /dev/null |
+++ b/tools/binary_size/PRESUBMIT.py |
@@ -0,0 +1,43 @@ |
+#!/usr/bin/env python |
Primiano Tucci (use gerrit)
2014/05/22 09:30:38
The PRESUBMIT.py shouldn't have a shbang and shoul
|
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""binary_size presubmit script |
+ |
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
+for more details about the presubmit API built into gcl. |
+""" |
+ |
+def _RunUnitTests(input_api, output_api): |
Primiano Tucci (use gerrit)
2014/05/22 09:30:38
Is there an actual reason why you didn't just copy
|
+ # Skip if nothing to do |
+ run_unit_test_path = input_api.os_path.join( |
+ input_api.PresubmitLocalPath(), 'explain_binary_size_delta_unittest.py') |
Primiano Tucci (use gerrit)
2014/05/22 09:30:38
We already have the mechanisms in place to run dis
|
+ cmd_name = 'explain_binary_size_delta_unittest' |
+ if input_api.platform == 'win32': |
Primiano Tucci (use gerrit)
2014/05/22 09:30:38
Neither we need platform specific black magic.
|
+ # Windows needs some help. |
+ cmd = [input_api.python_executable, run_unit_test_path] |
+ else: |
+ cmd = [run_unit_test_path] |
+ |
+ if input_api.is_committing: |
+ message_type = output_api.PresubmitError |
+ else: |
+ message_type = output_api.PresubmitPromptWarning |
+ |
+ test_cmd = input_api.Command( |
+ name=cmd_name, |
+ cmd=cmd, |
+ kwargs={}, |
+ message=message_type) |
+ if input_api.verbose: |
+ print('Running ' + cmd_name) |
+ return input_api.RunTests([test_cmd]) |
+ |
+ |
+def CheckChangeOnUpload(input_api, output_api): |
+ return _RunUnitTests(input_api, output_api) |
+ |
+ |
+def CheckChangeOnCommit(input_api, output_api): |
+ return _RunUnitTests(input_api, output_api) |