blob: 14d72c70e708d4ae14c6b60f2b798dae55a612f6 [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Presubmit script for Chromium browser code.
This script currently only checks HTML/CSS/JS files in resources/.
for more details about the presubmit API built into gcl/git cl, and see for the rules
checked for here.
def CheckChangeOnUpload(input_api, output_api):
return _CommonChecks(input_api, output_api)
def CheckChangeOnCommit(input_api, output_api):
return _CommonChecks(input_api, output_api)
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
path = input_api.os_path
cwd = input_api.PresubmitLocalPath()
resources = path.join(cwd, 'resources')
webui = path.join(cwd, 'ui', 'webui')
affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles())
would_affect_tests = (
path.join(cwd, ''),
path.join(cwd, ''),
path.join(cwd, 'web_dev_style', ''),
path.join(cwd, 'web_dev_style', ''),
if any(f for f in affected_files if f in would_affect_tests):
tests = [path.join(cwd, '')]
input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
import sys
old_path = sys.path
sys.path = [cwd] + old_path
from web_dev_style import resource_checker, css_checker, js_checker
search_dirs = (resources, webui)
def _html_css_js_resource(p):
return p.endswith(('.html', '.css', '.js')) and p.startswith(search_dirs)
BLACKLIST = ['chrome/browser/resources/pdf/index.html',
def is_resource(maybe_resource):
return (maybe_resource.LocalPath() not in BLACKLIST and
input_api, output_api, file_filter=is_resource).RunChecks())
input_api, output_api, file_filter=is_resource).RunChecks())
input_api, output_api, file_filter=is_resource).RunChecks())
sys.path = old_path
return results