cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / resources / PRESUBMIT.py
blob0aa0d6350df9b7b7482078d93211f0dd69a8a0ed
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
3 # found in the LICENSE file.
5 """Presubmit script for Chromium WebUI resources.
7 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
9 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here.
11 """
14 def CheckChangeOnUpload(input_api, output_api):
15 return _CommonChecks(input_api, output_api)
18 def CheckChangeOnCommit(input_api, output_api):
19 return _CommonChecks(input_api, output_api)
22 def _CommonChecks(input_api, output_api):
23 """Checks common to both upload and commit."""
24 results = []
25 resources = input_api.PresubmitLocalPath()
27 path = input_api.os_path
28 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles())
29 would_affect_tests = (
30 path.join(resources, 'PRESUBMIT.py'),
31 path.join(resources, 'test_presubmit.py'),
32 path.join(resources, 'web_dev_style', 'css_checker.py'),
33 path.join(resources, 'web_dev_style', 'js_checker.py'),
35 if any(f for f in affected_files if f in would_affect_tests):
36 tests = [path.join(resources, 'test_presubmit.py')]
37 results.extend(
38 input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
40 import sys
41 old_path = sys.path
43 try:
44 sys.path = [resources] + old_path
45 from web_dev_style import css_checker, js_checker
47 def _html_css_js_resource(p):
48 return p.endswith(('.html', '.css', '.js')) and p.startswith(resources)
50 def is_resource(maybe_resource):
51 return _html_css_js_resource(maybe_resource.AbsoluteLocalPath())
53 results.extend(css_checker.CSSChecker(
54 input_api, output_api, file_filter=is_resource).RunChecks())
55 results.extend(js_checker.JSChecker(
56 input_api, output_api, file_filter=is_resource).RunChecks())
57 finally:
58 sys.path = old_path
60 return results