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

Side by Side Diff: PRESUBMIT.py

Issue 2398263003: Added unittests for run_slave (Closed)
Patch Set: Pass infra_path via PYTHONPATH env variable. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | slave/tests/run_slave_test.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) 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 buildbot. 5 """Top-level presubmit script for buildbot.
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 git cl. 8 details on the presubmit API built into git cl.
9 """ 9 """
10 10
11 import contextlib 11 import contextlib
12 import os
12 import re 13 import re
13 import sys 14 import sys
14 15
15 16
16 @contextlib.contextmanager 17 @contextlib.contextmanager
17 def pythonpath(path): 18 def pythonpath(path):
18 orig = sys.path 19 orig = sys.path
19 try: 20 try:
20 sys.path = path 21 sys.path = path
21 yield 22 yield
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 recipe_modules_tests = input_api.glob( 122 recipe_modules_tests = input_api.glob(
122 join('scripts', 'slave', 'recipe_modules', '*', 'tests')) 123 join('scripts', 'slave', 'recipe_modules', '*', 'tests'))
123 for path in recipe_modules_tests: 124 for path in recipe_modules_tests:
124 tests.extend(input_api.canned_checks.GetUnitTestsInDirectory( 125 tests.extend(input_api.canned_checks.GetUnitTestsInDirectory(
125 input_api, 126 input_api,
126 output_api, 127 output_api,
127 path, 128 path,
128 whitelist)) 129 whitelist))
129 130
131 tests.extend(input_api.canned_checks.GetUnitTestsInDirectory(
132 input_api,
133 output_api,
134 input_api.os_path.join('slave', 'tests'),
135 whitelist,
136 env={'PYTHONPATH': os.pathsep.join(infra_path)}))
137
130 with pythonpath(infra_path + sys.path): 138 with pythonpath(infra_path + sys.path):
131 import common.master_cfg_utils # pylint: disable=F0401 139 import common.master_cfg_utils # pylint: disable=F0401
132 # Fetch recipe dependencies once in serial so that we don't hit a race 140 # Fetch recipe dependencies once in serial so that we don't hit a race
133 # condition where multiple tests are trying to fetch at once. 141 # condition where multiple tests are trying to fetch at once.
134 output = input_api.RunTests([input_api.Command( 142 output = input_api.RunTests([input_api.Command(
135 name='recipes fetch', 143 name='recipes fetch',
136 cmd=[input_api.python_executable, 144 cmd=[input_api.python_executable,
137 input_api.os_path.join('scripts', 'slave', 'recipes.py'), 'fetch'], 145 input_api.os_path.join('scripts', 'slave', 'recipes.py'), 'fetch'],
138 kwargs={}, 146 kwargs={},
139 message=output_api.PresubmitError, 147 message=output_api.PresubmitError,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 195
188 def CheckChangeOnUpload(_input_api, _output_api): 196 def CheckChangeOnUpload(_input_api, _output_api):
189 return [] # Try-jobs/commit-queue do a better job of testing, faster. 197 return [] # Try-jobs/commit-queue do a better job of testing, faster.
190 198
191 199
192 def CheckChangeOnCommit(input_api, output_api): 200 def CheckChangeOnCommit(input_api, output_api):
193 output = CommonChecks(input_api, output_api) 201 output = CommonChecks(input_api, output_api)
194 output.extend(ConditionalChecks(input_api, output_api)) 202 output.extend(ConditionalChecks(input_api, output_api))
195 output.extend(BuildInternalCheck(output, input_api, output_api)) 203 output.extend(BuildInternalCheck(output, input_api, output_api))
196 return output 204 return output
OLDNEW
« no previous file with comments | « no previous file | slave/tests/run_slave_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698