OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generic presubmit checks that can be reused by other presubmit checks.""" | 6 """Generic presubmit checks that can be reused by other presubmit checks.""" |
7 | 7 |
8 | 8 |
9 ### Description checks | 9 ### Description checks |
10 | 10 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 | 256 |
257 def CheckSvnProperty(input_api, output_api, prop, expected, affected_files): | 257 def CheckSvnProperty(input_api, output_api, prop, expected, affected_files): |
258 """Checks that affected_files files have prop=expected.""" | 258 """Checks that affected_files files have prop=expected.""" |
259 if input_api.change.scm != 'svn': | 259 if input_api.change.scm != 'svn': |
260 return [] | 260 return [] |
261 | 261 |
262 bad = filter(lambda f: f.Property(prop) != expected, affected_files) | 262 bad = filter(lambda f: f.Property(prop) != expected, affected_files) |
263 if bad: | 263 if bad: |
264 if input_api.is_committing: | 264 if input_api.is_committing: |
265 type = output_api.PresubmitError | 265 res_type = output_api.PresubmitError |
266 else: | 266 else: |
267 type = output_api.PresubmitNotifyResult | 267 res_type = output_api.PresubmitNotifyResult |
268 message = "Run `svn pset %s %s <item>` on these files:" % (prop, expected) | 268 message = "Run `svn pset %s %s <item>` on these files:" % (prop, expected) |
269 return [type(message, items=bad)] | 269 return [res_type(message, items=bad)] |
270 return [] | 270 return [] |
271 | 271 |
272 | 272 |
273 ### Other checks | 273 ### Other checks |
274 | 274 |
275 def CheckDoNotSubmit(input_api, output_api): | 275 def CheckDoNotSubmit(input_api, output_api): |
276 return ( | 276 return ( |
277 CheckDoNotSubmitInDescription(input_api, output_api) + | 277 CheckDoNotSubmitInDescription(input_api, output_api) + |
278 CheckDoNotSubmitInFiles(input_api, output_api) | 278 CheckDoNotSubmitInFiles(input_api, output_api) |
279 ) | 279 ) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 stderr=input_api.subprocess.PIPE) | 342 stderr=input_api.subprocess.PIPE) |
343 stdoutdata, stderrdata = subproc.communicate() | 343 stdoutdata, stderrdata = subproc.communicate() |
344 # Discard the output if returncode == 0 | 344 # Discard the output if returncode == 0 |
345 if subproc.returncode: | 345 if subproc.returncode: |
346 outputs.append("Test '%s' failed with code %d\n%s\n%s\n" % ( | 346 outputs.append("Test '%s' failed with code %d\n%s\n%s\n" % ( |
347 unit_test_name, subproc.returncode, stdoutdata, stderrdata)) | 347 unit_test_name, subproc.returncode, stdoutdata, stderrdata)) |
348 if outputs: | 348 if outputs: |
349 return [message_type("%d unit tests failed." % len(outputs), | 349 return [message_type("%d unit tests failed." % len(outputs), |
350 long_text='\n'.join(outputs))] | 350 long_text='\n'.join(outputs))] |
351 return [] | 351 return [] |
OLD | NEW |