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

Side by Side Diff: presubmit_canned_checks.py

Issue 7860041: Update subprocess2.check_output() to behave like subprocess.check_output(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: update comment and docstring, they were unclear Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 cmd = [input_api.python_executable] 508 cmd = [input_api.python_executable]
509 cmd.append(unit_test) 509 cmd.append(unit_test)
510 if input_api.verbose: 510 if input_api.verbose:
511 print('Running %s' % unit_test) 511 print('Running %s' % unit_test)
512 cmd.append('--verbose') 512 cmd.append('--verbose')
513 try: 513 try:
514 if input_api.verbose: 514 if input_api.verbose:
515 input_api.subprocess.check_call(cmd, cwd=input_api.PresubmitLocalPath()) 515 input_api.subprocess.check_call(cmd, cwd=input_api.PresubmitLocalPath())
516 else: 516 else:
517 input_api.subprocess.check_output( 517 input_api.subprocess.check_output(
518 cmd, cwd=input_api.PresubmitLocalPath()) 518 cmd,
519 stderr=input_api.subprocess.STDOUT,
520 cwd=input_api.PresubmitLocalPath())
519 except (OSError, input_api.subprocess.CalledProcessError), e: 521 except (OSError, input_api.subprocess.CalledProcessError), e:
520 results.append(message_type('%s failed!\n%s' % (unit_test, e))) 522 results.append(message_type('%s failed!\n%s' % (unit_test, e)))
521 return results 523 return results
522 524
523 525
524 def RunPythonUnitTests(input_api, output_api, unit_tests): 526 def RunPythonUnitTests(input_api, output_api, unit_tests):
525 """Run the unit tests out of process, capture the output and use the result 527 """Run the unit tests out of process, capture the output and use the result
526 code to determine success. 528 code to determine success.
527 529
528 DEPRECATED. 530 DEPRECATED.
(...skipping 22 matching lines...) Expand all
551 env = input_api.environ.copy() 553 env = input_api.environ.copy()
552 # At least on Windows, it seems '.' must explicitly be in PYTHONPATH 554 # At least on Windows, it seems '.' must explicitly be in PYTHONPATH
553 backpath = [ 555 backpath = [
554 '.', input_api.os_path.pathsep.join(['..'] * (cwd.count('/') + 1)) 556 '.', input_api.os_path.pathsep.join(['..'] * (cwd.count('/') + 1))
555 ] 557 ]
556 if env.get('PYTHONPATH'): 558 if env.get('PYTHONPATH'):
557 backpath.append(env.get('PYTHONPATH')) 559 backpath.append(env.get('PYTHONPATH'))
558 env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath)) 560 env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath))
559 cmd = [input_api.python_executable, '-m', '%s' % unit_test] 561 cmd = [input_api.python_executable, '-m', '%s' % unit_test]
560 try: 562 try:
561 input_api.subprocess.check_output(cmd, cwd=cwd, env=env) 563 input_api.subprocess.check_output(
564 cmd, stderr=input_api.subprocess.STDOUT, cwd=cwd, env=env)
562 except (OSError, input_api.subprocess.CalledProcessError), e: 565 except (OSError, input_api.subprocess.CalledProcessError), e:
563 results.append(message_type('%s failed!\n%s' % (unit_test_name, e))) 566 results.append(message_type('%s failed!\n%s' % (unit_test_name, e)))
564 return results 567 return results
565 568
566 569
567 def _FetchAllFiles(input_api, white_list, black_list): 570 def _FetchAllFiles(input_api, white_list, black_list):
568 """Hack to fetch all files.""" 571 """Hack to fetch all files."""
569 # We cannot use AffectedFiles here because we want to test every python 572 # We cannot use AffectedFiles here because we want to test every python
570 # file on each single python change. It's because a change in a python file 573 # file on each single python change. It's because a change in a python file
571 # can break another unmodified file. 574 # can break another unmodified file.
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 942 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
940 input_api, output_api)) 943 input_api, output_api))
941 snapshot("checking license") 944 snapshot("checking license")
942 results.extend(input_api.canned_checks.CheckLicense( 945 results.extend(input_api.canned_checks.CheckLicense(
943 input_api, output_api, license_header, source_file_filter=sources)) 946 input_api, output_api, license_header, source_file_filter=sources))
944 snapshot("checking was uploaded") 947 snapshot("checking was uploaded")
945 results.extend(input_api.canned_checks.CheckChangeWasUploaded( 948 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
946 input_api, output_api)) 949 input_api, output_api))
947 snapshot("done") 950 snapshot("done")
948 return results 951 return results
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698