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

Side by Side Diff: reviewbot/PRESUBMIT.py

Issue 20518002: Implement mail dispatcher app. (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | reviewbot/app.yaml » ('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) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 reviewbot. 5 """Top-level presubmit script for reviewbot.
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 gcl. 8 details on the presubmit API built into gcl.
9 """ 9 """
10 10
11 def GetUnitTests(input_api, output_api, pythonpath):
12 """Finds all unit tests to run within the source tree."""
13 tests = []
14 for root, dirs, files in input_api.os_walk(input_api.PresubmitLocalPath()):
15 # Don't recurse in blacklisted directories.
16 blacklist = ['.svn', '.git', 'third_party']
17 dirs[:] = filter(lambda d : d not in blacklist, dirs)
18
19 # Add all files ending in _test.py to the list of tests.
20 test_files = filter(lambda f: f.endswith('_test.py'), files)
21 tests.extend([input_api.os_path.join(root, f) for f in test_files])
22
23 # A helper to augment PYTHONPATH in the unit test command environment.
24 def augment_pythonpath_in_environment(cmd):
25 env = cmd.kwargs.get('env', {})
26 new_env_path = input_api.os_path.pathsep.join(pythonpath)
27 if 'PYTHONPATH' in env:
28 new_env_path += input_api.os_path.pathsep + env['PYTHONPATH']
29 env['PYTHONPATH'] = new_env_path
30 cmd.kwargs['env'] = env
31 return cmd
32
33 # Create the commands.
34 return map(
35 augment_pythonpath_in_environment,
36 input_api.canned_checks.GetUnitTests(input_api, output_api, tests))
37
11 38
12 def CommonChecks(input_api, output_api): 39 def CommonChecks(input_api, output_api):
13 output = [] 40 output = []
14 41
15 join = input_api.os_path.join 42 join = input_api.os_path.join
16 root = input_api.PresubmitLocalPath() 43 root = input_api.PresubmitLocalPath()
17 while True: 44 while True:
18 if input_api.os_path.isfile(join(root, 'google_appengine', 'VERSION')): 45 if input_api.os_path.isfile(join(root, 'google_appengine', 'VERSION')):
19 break 46 break
20 next_root = input_api.os_path.dirname(root) 47 next_root = input_api.os_path.dirname(root)
21 if next_root == root: 48 if next_root == root:
22 return [output_api.PresubmitError('Failed to find Google AppEngine SDK')] 49 return [output_api.PresubmitError('Failed to find Google AppEngine SDK')]
23 root = next_root 50 root = next_root
24 input_api.logging.debug('Found GAE SDK in %s' % root) 51 input_api.logging.debug('Found GAE SDK in %s' % root)
25 52
26 import sys 53 import sys
27 sys_path_backup = sys.path 54 sys_path_backup = sys.path
28 try: 55 try:
29 sys.path = [ 56 sys.path = [
30 join(root, 'google_appengine'), 57 join(root, 'google_appengine'),
31 join(root, 'google_appengine', 'lib'), 58 join(root, 'google_appengine', 'lib'),
32 join(root, 'google_appengine', 'lib', 'webapp2-2.5.2'), 59 join(root, 'google_appengine', 'lib', 'webapp2-2.5.2'),
33 join(root, 'google_appengine', 'lib', 'webob-1.2.3'), 60 join(root, 'google_appengine', 'lib', 'webob-1.2.3'),
34 join('third_party', 'google-api-python-client'), 61 join('third_party', 'google-api-python-client'),
62 input_api.PresubmitLocalPath(),
35 ] + sys.path 63 ] + sys.path
36 output.extend(input_api.canned_checks.RunPylint( 64
37 input_api, 65 output.extend(input_api.RunTests(
38 output_api)) 66 input_api.canned_checks.GetPylint(
67 input_api,
68 output_api) +
69 GetUnitTests(input_api, output_api, sys.path)))
39 finally: 70 finally:
40 sys.path = sys_path_backup 71 sys.path = sys_path_backup
41 72
42 output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
43 input_api,
44 output_api,
45 '.',
46 whitelist=[r'.*_test\.py$']))
47
48 return output 73 return output
49 74
50 75
51 def CheckChangeOnUpload(input_api, output_api): 76 def CheckChangeOnUpload(input_api, output_api):
52 return CommonChecks(input_api, output_api) 77 return CommonChecks(input_api, output_api)
53 78
54 79
55 def CheckChangeOnCommit(input_api, output_api): 80 def CheckChangeOnCommit(input_api, output_api):
56 return CommonChecks(input_api, output_api) 81 return CommonChecks(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | reviewbot/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698