OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Top-level presubmit script for depot tools. | 5 """Top-level presubmit script for depot tools. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
8 details on the presubmit API built into depot_tools. | 8 details on the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 """ | 47 """ |
48 if input_api.platform == 'win32': | 48 if input_api.platform == 'win32': |
49 # Skip for now as long as the test scripts are bash scripts. | 49 # Skip for now as long as the test scripts are bash scripts. |
50 return [] | 50 return [] |
51 | 51 |
52 # First loads a local Rietveld instance. | 52 # First loads a local Rietveld instance. |
53 import sys | 53 import sys |
54 old_sys_path = sys.path | 54 old_sys_path = sys.path |
55 try: | 55 try: |
56 sys.path = [input_api.PresubmitLocalPath()] + sys.path | 56 sys.path = [input_api.PresubmitLocalPath()] + sys.path |
57 print input_api.PresubmitLocalPath() | |
Dirk Pranke
2013/06/26 01:18:44
I don't think you actually want this print stateme
Ryan Tseng
2013/06/26 01:29:06
Oops, fixed.
| |
57 from testing_support import local_rietveld | 58 from testing_support import local_rietveld |
58 server = local_rietveld.LocalRietveld() | 59 server = local_rietveld.LocalRietveld() |
59 finally: | 60 finally: |
60 sys.path = old_sys_path | 61 sys.path = old_sys_path |
61 | 62 |
62 results = [] | 63 results = [] |
64 input_api.environ['PATH'] = '%s:%s' % (input_api.PresubmitLocalPath(), | |
iannucci
2013/06/26 01:18:23
use os.pathsep instead of ':'
Ryan Tseng
2013/06/26 01:29:06
Done.
| |
65 input_api.environ['PATH']) | |
63 try: | 66 try: |
64 # Start a local rietveld instance to test against. | 67 # Start a local rietveld instance to test against. |
65 server.start_server() | 68 server.start_server() |
66 test_path = input_api.os_path.abspath( | 69 test_path = input_api.os_path.abspath( |
67 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests')) | 70 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests')) |
68 for test in input_api.os_listdir(test_path): | 71 for test in input_api.os_listdir(test_path): |
69 # test-lib.sh is not an actual test so it should not be run. The other | 72 # test-lib.sh is not an actual test so it should not be run. The other |
70 # tests are tests known to fail. | 73 # tests are tests known to fail. |
71 DISABLED_TESTS = ( | 74 DISABLED_TESTS = ( |
72 'owners.sh', 'push-from-logs.sh', 'rename.sh', 'test-lib.sh') | 75 'owners.sh', 'push-from-logs.sh', 'rename.sh', 'test-lib.sh') |
73 if test in DISABLED_TESTS or not test.endswith('.sh'): | 76 if test in DISABLED_TESTS or not test.endswith('.sh'): |
74 continue | 77 continue |
75 | 78 |
76 print('Running %s' % test) | 79 print('Running %s' % test) |
77 try: | 80 try: |
78 if input_api.verbose: | 81 if input_api.verbose: |
79 input_api.subprocess.check_call( | 82 input_api.subprocess.check_call( |
80 [input_api.os_path.join(test_path, test)], cwd=test_path) | 83 [input_api.os_path.join(test_path, test)], cwd=test_path, |
84 env=input_api.environ) | |
81 else: | 85 else: |
82 input_api.subprocess.check_output( | 86 input_api.subprocess.check_output( |
83 [input_api.os_path.join(test_path, test)], cwd=test_path, | 87 [input_api.os_path.join(test_path, test)], cwd=test_path, |
84 stderr=input_api.subprocess.STDOUT) | 88 stderr=input_api.subprocess.STDOUT, env=input_api.environ) |
85 except (OSError, input_api.subprocess.CalledProcessError), e: | 89 except (OSError, input_api.subprocess.CalledProcessError), e: |
86 results.append(output_api.PresubmitError('%s failed\n%s' % (test, e))) | 90 results.append(output_api.PresubmitError('%s failed\n%s' % (test, e))) |
87 except local_rietveld.Failure, e: | 91 except local_rietveld.Failure, e: |
88 results.append(output_api.PresubmitError('\n'.join(str(i) for i in e.args))) | 92 results.append(output_api.PresubmitError('\n'.join(str(i) for i in e.args))) |
89 finally: | 93 finally: |
90 server.stop_server() | 94 server.stop_server() |
91 return results | 95 return results |
92 | 96 |
93 | 97 |
94 def CheckChangeOnUpload(input_api, output_api): | 98 def CheckChangeOnUpload(input_api, output_api): |
95 # Do not run integration tests on upload since they are way too slow. | 99 # Do not run integration tests on upload since they are way too slow. |
96 tests_to_black_list = [ | 100 tests_to_black_list = [ |
97 r'^checkout_test\.py$', | 101 r'^checkout_test\.py$', |
98 r'^gclient_smoketest\.py$', | 102 r'^gclient_smoketest\.py$', |
99 r'^scm_unittest\.py$', | 103 r'^scm_unittest\.py$', |
100 r'^subprocess2_test\.py$', | 104 r'^subprocess2_test\.py$', |
101 ] | 105 ] |
102 return CommonChecks(input_api, output_api, tests_to_black_list) | 106 return CommonChecks(input_api, output_api, tests_to_black_list) |
103 | 107 |
104 | 108 |
105 def CheckChangeOnCommit(input_api, output_api): | 109 def CheckChangeOnCommit(input_api, output_api): |
106 output = [] | 110 output = [] |
107 output.extend(CommonChecks(input_api, output_api, [])) | 111 output.extend(CommonChecks(input_api, output_api, [])) |
108 output.extend(input_api.canned_checks.CheckDoNotSubmit( | 112 output.extend(input_api.canned_checks.CheckDoNotSubmit( |
109 input_api, | 113 input_api, |
110 output_api)) | 114 output_api)) |
111 output.extend(RunGitClTests(input_api, output_api)) | 115 output.extend(RunGitClTests(input_api, output_api)) |
112 return output | 116 return output |
OLD | NEW |