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 ### Description checks | 8 ### Description checks |
9 | 9 |
10 def CheckChangeHasTestField(input_api, output_api): | 10 def CheckChangeHasTestField(input_api, output_api): |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 """Checks that affected_files files have prop=expected.""" | 302 """Checks that affected_files files have prop=expected.""" |
303 if input_api.change.scm != 'svn': | 303 if input_api.change.scm != 'svn': |
304 return [] | 304 return [] |
305 | 305 |
306 bad = filter(lambda f: f.Property(prop) != expected, affected_files) | 306 bad = filter(lambda f: f.Property(prop) != expected, affected_files) |
307 if bad: | 307 if bad: |
308 if input_api.is_committing: | 308 if input_api.is_committing: |
309 res_type = output_api.PresubmitError | 309 res_type = output_api.PresubmitError |
310 else: | 310 else: |
311 res_type = output_api.PresubmitNotifyResult | 311 res_type = output_api.PresubmitNotifyResult |
312 message = "Run `svn pset %s %s <item>` on these files:" % (prop, expected) | 312 message = "Run the command: svn pset %s %s \\" % (prop, expected) |
313 return [res_type(message, items=bad)] | 313 return [res_type(message, items=bad)] |
314 return [] | 314 return [] |
315 | 315 |
316 | 316 |
317 ### Other checks | 317 ### Other checks |
318 | 318 |
319 def CheckDoNotSubmit(input_api, output_api): | 319 def CheckDoNotSubmit(input_api, output_api): |
320 return ( | 320 return ( |
321 CheckDoNotSubmitInDescription(input_api, output_api) + | 321 CheckDoNotSubmitInDescription(input_api, output_api) + |
322 CheckDoNotSubmitInFiles(input_api, output_api) | 322 CheckDoNotSubmitInFiles(input_api, output_api) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 stderr=input_api.subprocess.PIPE) | 386 stderr=input_api.subprocess.PIPE) |
387 stdoutdata, stderrdata = subproc.communicate() | 387 stdoutdata, stderrdata = subproc.communicate() |
388 # Discard the output if returncode == 0 | 388 # Discard the output if returncode == 0 |
389 if subproc.returncode: | 389 if subproc.returncode: |
390 outputs.append("Test '%s' failed with code %d\n%s\n%s\n" % ( | 390 outputs.append("Test '%s' failed with code %d\n%s\n%s\n" % ( |
391 unit_test_name, subproc.returncode, stdoutdata, stderrdata)) | 391 unit_test_name, subproc.returncode, stdoutdata, stderrdata)) |
392 if outputs: | 392 if outputs: |
393 return [message_type("%d unit tests failed." % len(outputs), | 393 return [message_type("%d unit tests failed." % len(outputs), |
394 long_text='\n'.join(outputs))] | 394 long_text='\n'.join(outputs))] |
395 return [] | 395 return [] |
OLD | NEW |