Turning WebGL and the accelerated compositor on by default (linux and windows only...
[chromium-blink-merge.git] / o3d / PRESUBMIT.py
blobc80f02ef45416cb8dbe6565f9661e00ec644913d
1 # Copyright 2009, Google Inc.
2 # All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 import os
31 import sys
33 EXCLUDED_PATHS = (
34 r"breakpad[\\\/].*",
35 r"o3d_assets[\\\/].*",
36 r"third_party[\\\/].*",
39 def FindOnPage(input_api, url, regex):
40 """Given a url, download it and find the part matching a regex.
41 Arguments:
42 input_api: the limited set of input modules allowed in presubmit
43 url: url to download
44 regex: regex to match on
45 Returns:
46 A string extracted from the match, or None if no match or error.
47 """
48 try:
49 connection = input_api.urllib2.urlopen(url)
50 text = connection.read()
51 connection.close()
52 match = input_api.re.search(regex, text)
53 if match:
54 return match.group(1)
55 else:
56 return None
57 except IOError, e:
58 print str(e)
59 return None
62 def CheckTreeIsOpen(input_api, output_api, url, url_text):
63 """Similar to the one in presubmit_canned_checks except it shows an helpful
64 status text instead.
65 Arguments:
66 input_api: the limited set of input modules allowed in presubmit
67 output_api: the limited set of output modules allowed in presubmit
68 url: url to get numerical tree status from
69 url_text: url to get human readable tree status from
70 regex: regex to match on
71 Returns:
72 A list of presubmit warnings.
73 """
74 assert(input_api.is_committing)
75 # Check if tree is open.
76 status = FindOnPage(input_api, url, '([0-9]+)')
77 if status and int(status):
78 return []
79 # Try to find out what failed.
80 message = FindOnPage(input_api, url_text,
81 r'\<div class\="Notice"\>(.*)\<\/div\>')
82 if message:
83 return [output_api.PresubmitPromptWarning("The tree is closed.",
84 long_text=message.strip())]
85 # Report unknown reason.
86 return [output_api.PresubmitPromptWarning(
87 "The tree status can't be checked.")]
90 def CheckChangeOnUpload(input_api, output_api):
91 report = []
92 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDED_PATHS
93 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list)
94 report.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
95 input_api, output_api, sources))
96 return report
99 def CheckChangeOnCommit(input_api, output_api):
100 report = []
101 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDED_PATHS
102 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list)
103 report.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
104 input_api, output_api, sources))
105 report.extend(CheckTreeIsOpen(
106 input_api, output_api,
107 'http://o3d-status.appspot.com/status',
108 'http://o3d-status.appspot.com/current'))
109 return report