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

Side by Side Diff: chrome/browser/PRESUBMIT.py

Issue 253543002: web_dev_style: check webui browser tests as well. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 7 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 | « chrome/browser/OWNERS ('k') | chrome/browser/resources/PRESUBMIT.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 2014 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 """Presubmit script for Chromium WebUI resources. 5 """Presubmit script for Chromium browser code.
6
7 This script currently only checks HTML/CSS/JS files in resources/.
6 8
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl/git cl, and see 10 for more details about the presubmit API built into gcl/git cl, and see
9 http://www.chromium.org/developers/web-development-style-guide for the rules 11 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here. 12 checked for here.
11 """ 13 """
12 14
13 15
14 def CheckChangeOnUpload(input_api, output_api): 16 def CheckChangeOnUpload(input_api, output_api):
15 return _CommonChecks(input_api, output_api) 17 return _CommonChecks(input_api, output_api)
16 18
17 19
18 def CheckChangeOnCommit(input_api, output_api): 20 def CheckChangeOnCommit(input_api, output_api):
19 return _CommonChecks(input_api, output_api) 21 return _CommonChecks(input_api, output_api)
20 22
21 23
22 def _CommonChecks(input_api, output_api): 24 def _CommonChecks(input_api, output_api):
23 """Checks common to both upload and commit.""" 25 """Checks common to both upload and commit."""
24 results = [] 26 results = []
25 resources = input_api.PresubmitLocalPath()
26 27
27 path = input_api.os_path 28 path = input_api.os_path
29 cwd = input_api.PresubmitLocalPath()
30 resources = path.join(cwd, 'resources')
31 webui = path.join(cwd, 'ui', 'webui')
32
28 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()) 33 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles())
29 would_affect_tests = ( 34 would_affect_tests = (
30 path.join(resources, 'PRESUBMIT.py'), 35 path.join(cwd, 'PRESUBMIT.py'),
31 path.join(resources, 'test_presubmit.py'), 36 path.join(cwd, 'test_presubmit.py'),
32 path.join(resources, 'web_dev_style', 'css_checker.py'), 37 path.join(cwd, 'web_dev_style', 'css_checker.py'),
33 path.join(resources, 'web_dev_style', 'js_checker.py'), 38 path.join(cwd, 'web_dev_style', 'js_checker.py'),
34 ) 39 )
35 if any(f for f in affected_files if f in would_affect_tests): 40 if any(f for f in affected_files if f in would_affect_tests):
36 tests = [path.join(resources, 'test_presubmit.py')] 41 tests = [path.join(cwd, 'test_presubmit.py')]
37 results.extend( 42 results.extend(
38 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) 43 input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
39 44
40 import sys 45 import sys
41 old_path = sys.path 46 old_path = sys.path
42 47
43 try: 48 try:
44 sys.path = [resources] + old_path 49 sys.path = [cwd] + old_path
45 from web_dev_style import css_checker, js_checker 50 from web_dev_style import css_checker, js_checker
46 51
52 search_dirs = (resources, webui)
47 def _html_css_js_resource(p): 53 def _html_css_js_resource(p):
48 return p.endswith(('.html', '.css', '.js')) and p.startswith(resources) 54 return p.endswith(('.html', '.css', '.js')) and p.startswith(search_dirs)
49 55
50 BLACKLIST = ['chrome/browser/resources/pdf/index.html', 56 BLACKLIST = ['chrome/browser/resources/pdf/index.html',
51 'chrome/browser/resources/pdf/index.js'] 57 'chrome/browser/resources/pdf/index.js']
52 def is_resource(maybe_resource): 58 def is_resource(maybe_resource):
53 return (maybe_resource.LocalPath() not in BLACKLIST and 59 return (maybe_resource.LocalPath() not in BLACKLIST and
54 _html_css_js_resource(maybe_resource.AbsoluteLocalPath())) 60 _html_css_js_resource(maybe_resource.AbsoluteLocalPath()))
55 61
56 results.extend(css_checker.CSSChecker( 62 results.extend(css_checker.CSSChecker(
57 input_api, output_api, file_filter=is_resource).RunChecks()) 63 input_api, output_api, file_filter=is_resource).RunChecks())
58 results.extend(js_checker.JSChecker( 64 results.extend(js_checker.JSChecker(
59 input_api, output_api, file_filter=is_resource).RunChecks()) 65 input_api, output_api, file_filter=is_resource).RunChecks())
60 finally: 66 finally:
61 sys.path = old_path 67 sys.path = old_path
62 68
63 return results 69 return results
OLDNEW
« no previous file with comments | « chrome/browser/OWNERS ('k') | chrome/browser/resources/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698