OLD | NEW |
---|---|
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
11 # with the distribution. | 11 # with the distribution. |
12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
15 # | 15 # |
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 import os | |
28 | 29 |
29 # These outcomes can occur in a TestCase's outcomes list: | 30 # These outcomes can occur in a TestCase's outcomes list: |
30 SKIP = "SKIP" | 31 SKIP = "SKIP" |
31 FAIL = "FAIL" | 32 FAIL = "FAIL" |
32 PASS = "PASS" | 33 PASS = "PASS" |
33 OKAY = "OKAY" | 34 OKAY = "OKAY" |
34 TIMEOUT = "TIMEOUT" | 35 TIMEOUT = "TIMEOUT" |
35 CRASH = "CRASH" | 36 CRASH = "CRASH" |
36 SLOW = "SLOW" | 37 SLOW = "SLOW" |
37 FLAKY = "FLAKY" | 38 FLAKY = "FLAKY" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 _AddOutcome(result, outcome) | 119 _AddOutcome(result, outcome) |
119 else: | 120 else: |
120 assert False | 121 assert False |
121 if len(result) == 0: return | 122 if len(result) == 0: return |
122 if rule in target_dict: | 123 if rule in target_dict: |
123 target_dict[rule] |= result | 124 target_dict[rule] |= result |
124 else: | 125 else: |
125 target_dict[rule] = result | 126 target_dict[rule] = result |
126 | 127 |
127 | 128 |
128 def ReadStatusFile(path, variables): | 129 def ReadContent(path): |
129 with open(path) as f: | 130 with open(path) as f: |
130 global KEYWORDS | 131 global KEYWORDS |
131 contents = eval(f.read(), KEYWORDS) | 132 return eval(f.read(), KEYWORDS) |
133 | |
134 | |
135 def ReadStatusFile(path, variables): | |
136 contents = ReadContent(path) | |
132 | 137 |
133 rules = {} | 138 rules = {} |
134 wildcards = {} | 139 wildcards = {} |
135 variables.update(VARIABLES) | 140 variables.update(VARIABLES) |
136 for section in contents: | 141 for section in contents: |
137 assert type(section) == list | 142 assert type(section) == list |
Jakob Kummerow
2015/11/25 11:04:17
we could consider dropping this (as presubmit chec
| |
138 assert len(section) == 2 | 143 assert len(section) == 2 |
139 if not eval(section[0], variables): continue | 144 if not eval(section[0], variables): continue |
140 section = section[1] | 145 section = section[1] |
141 assert type(section) == dict | 146 assert type(section) == dict |
142 for rule in section: | 147 for rule in section: |
143 assert type(rule) == str | 148 assert type(rule) == str |
144 if rule[-1] == '*': | 149 if rule[-1] == '*': |
145 _ParseOutcomeList(rule, section[rule], wildcards, variables) | 150 _ParseOutcomeList(rule, section[rule], wildcards, variables) |
146 else: | 151 else: |
147 _ParseOutcomeList(rule, section[rule], rules, variables) | 152 _ParseOutcomeList(rule, section[rule], rules, variables) |
148 return rules, wildcards | 153 return rules, wildcards |
154 | |
155 | |
156 def PresubmitCheck(path): | |
157 contents = ReadContent(path) | |
158 root_prefix = os.path.basename(os.path.dirname(path)) + "/" | |
159 | |
160 try: | |
161 for section in contents: | |
162 assert type(section) == list | |
Jakob Kummerow
2015/11/25 11:04:17
This checker bails out on the first error it finds
| |
163 assert len(section) == 2 | |
164 section = section[1] | |
165 assert type(section) == dict | |
166 for rule in section: | |
167 assert type(rule) == str | |
168 assert not rule.startswith(root_prefix), ( | |
169 "Suite name prefix must not be used in status files") | |
170 assert not rule.endswith('.js'), ( | |
171 ".js extension must not be used in status files.") | |
172 return True | |
173 except Exception as e: | |
174 print e | |
175 return False | |
OLD | NEW |