Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / activity_log_private / PRESUBMIT.py
blob52f5f39b80fe30219bc12c87eec60f7f0b73c2fc
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 """Run the Chrome WebUI presubmit scripts on our test javascript.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools, and see
9 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here.
11 """
13 import os
15 def GetPathsToPrepend(input_api):
16 web_dev_style_path = input_api.os_path.join(
17 input_api.change.RepositoryRoot(),
18 'chrome',
19 'browser',
20 'resources')
21 return [input_api.PresubmitLocalPath(), web_dev_style_path]
23 def RunWithPrependedPath(prepended_path, fn, *args):
24 import sys
25 old_path = sys.path
27 try:
28 sys.path = prepended_path + old_path
29 return fn(*args)
30 finally:
31 sys.path = old_path
33 def CheckChangeOnUpload(input_api, output_api):
34 def go():
35 results = []
36 results.extend(_CommonChecks(input_api, output_api))
37 return results
38 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)
40 def CheckChangeOnCommit(input_api, output_api):
41 def go():
42 results = []
43 results.extend(_CommonChecks(input_api, output_api))
44 return results
45 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)
47 def _CommonChecks(input_api, output_api):
48 resources = input_api.PresubmitLocalPath()
50 def _html_css_js_resource(p):
51 return p.endswith(('.js')) and p.startswith(resources)
53 def is_resource(maybe_resource):
54 return _html_css_js_resource(maybe_resource.AbsoluteLocalPath())
56 from web_dev_style import js_checker
58 results = []
59 results.extend(js_checker.JSChecker(
60 input_api, output_api, file_filter=is_resource).RunChecks())
62 return results