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

Side by Side Diff: presubmit_canned_checks.py

Issue 193004: Added "gclient pack" subcommand, which generates a patch relative to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 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
OLDNEW
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 unit_test_name = unit_test 315 unit_test_name = unit_test
316 # "python -m test.unit_test" doesn't work. We need to change to the right 316 # "python -m test.unit_test" doesn't work. We need to change to the right
317 # directory instead. 317 # directory instead.
318 if '.' in unit_test: 318 if '.' in unit_test:
319 # Tests imported in submodules (subdirectories) assume that the current 319 # Tests imported in submodules (subdirectories) assume that the current
320 # directory is in the PYTHONPATH. Manually fix that. 320 # directory is in the PYTHONPATH. Manually fix that.
321 unit_test = unit_test.replace('.', '/') 321 unit_test = unit_test.replace('.', '/')
322 cwd = input_api.os_path.dirname(unit_test) 322 cwd = input_api.os_path.dirname(unit_test)
323 unit_test = input_api.os_path.basename(unit_test) 323 unit_test = input_api.os_path.basename(unit_test)
324 env = input_api.environ.copy() 324 env = input_api.environ.copy()
325 backpath = [input_api.os_path.pathsep.join(['..'] * (cwd.count('/') + 1))] 325 # At least on Windows, it seems '.' must explicitly be in PYTHONPATH
326 backpath = [
327 '.', input_api.os_path.pathsep.join(['..'] * (cwd.count('/') + 1))
328 ]
326 if env.get('PYTHONPATH'): 329 if env.get('PYTHONPATH'):
327 backpath.append(env.get('PYTHONPATH')) 330 backpath.append(env.get('PYTHONPATH'))
328 env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath)) 331 env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath))
329 subproc = input_api.subprocess.Popen( 332 subproc = input_api.subprocess.Popen(
330 [ 333 [
331 input_api.python_executable, 334 input_api.python_executable,
332 "-m", 335 "-m",
333 "%s" % unit_test 336 "%s" % unit_test
334 ], 337 ],
335 cwd=cwd, 338 cwd=cwd,
336 env=env, 339 env=env,
337 stdin=input_api.subprocess.PIPE, 340 stdin=input_api.subprocess.PIPE,
338 stdout=input_api.subprocess.PIPE, 341 stdout=input_api.subprocess.PIPE,
339 stderr=input_api.subprocess.PIPE) 342 stderr=input_api.subprocess.PIPE)
340 stdoutdata, stderrdata = subproc.communicate() 343 stdoutdata, stderrdata = subproc.communicate()
341 # Discard the output if returncode == 0 344 # Discard the output if returncode == 0
342 if subproc.returncode: 345 if subproc.returncode:
343 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" % (
344 unit_test_name, subproc.returncode, stdoutdata, stderrdata)) 347 unit_test_name, subproc.returncode, stdoutdata, stderrdata))
345 if outputs: 348 if outputs:
346 return [message_type("%d unit tests failed." % len(outputs), 349 return [message_type("%d unit tests failed." % len(outputs),
347 long_text='\n'.join(outputs))] 350 long_text='\n'.join(outputs))]
348 return [] 351 return []
OLDNEW
« gclient.py ('K') | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698