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 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 def _ReadSection(section, rules, wildcards, variables): | 226 def _ReadSection(section, rules, wildcards, variables): |
227 assert type(section) == dict | 227 assert type(section) == dict |
228 for rule in section: | 228 for rule in section: |
229 assert type(rule) == str | 229 assert type(rule) == str |
230 if rule[-1] == '*': | 230 if rule[-1] == '*': |
231 _ParseOutcomeList(rule, section[rule], wildcards, variables) | 231 _ParseOutcomeList(rule, section[rule], wildcards, variables) |
232 else: | 232 else: |
233 _ParseOutcomeList(rule, section[rule], rules, variables) | 233 _ParseOutcomeList(rule, section[rule], rules, variables) |
234 | 234 |
| 235 JS_TEST_PATHS = { |
| 236 'debugger': [[]], |
| 237 'inspector': [[]], |
| 238 'intl': [[]], |
| 239 'message': [[]], |
| 240 'mjsunit': [[]], |
| 241 'mozilla': [['data']], |
| 242 'test262': [['data', 'test'], ['local-tests', 'test']], |
| 243 'webkit': [[]], |
| 244 } |
235 | 245 |
236 def PresubmitCheck(path): | 246 def PresubmitCheck(path): |
237 with open(path) as f: | 247 with open(path) as f: |
238 contents = ReadContent(f.read()) | 248 contents = ReadContent(f.read()) |
239 root_prefix = os.path.basename(os.path.dirname(path)) + "/" | 249 basename = os.path.basename(os.path.dirname(path)) |
| 250 root_prefix = basename + "/" |
240 status = {"success": True} | 251 status = {"success": True} |
241 def _assert(check, message): # Like "assert", but doesn't throw. | 252 def _assert(check, message): # Like "assert", but doesn't throw. |
242 if not check: | 253 if not check: |
243 print("%s: Error: %s" % (path, message)) | 254 print("%s: Error: %s" % (path, message)) |
244 status["success"] = False | 255 status["success"] = False |
245 try: | 256 try: |
246 for section in contents: | 257 for section in contents: |
247 _assert(type(section) == list, "Section must be a list") | 258 _assert(type(section) == list, "Section must be a list") |
248 _assert(len(section) == 2, "Section list must have exactly 2 entries") | 259 _assert(len(section) == 2, "Section list must have exactly 2 entries") |
249 section = section[1] | 260 section = section[1] |
250 _assert(type(section) == dict, | 261 _assert(type(section) == dict, |
251 "Second entry of section must be a dictionary") | 262 "Second entry of section must be a dictionary") |
252 for rule in section: | 263 for rule in section: |
253 _assert(type(rule) == str, "Rule key must be a string") | 264 _assert(type(rule) == str, "Rule key must be a string") |
254 _assert(not rule.startswith(root_prefix), | 265 _assert(not rule.startswith(root_prefix), |
255 "Suite name prefix must not be used in rule keys") | 266 "Suite name prefix must not be used in rule keys") |
256 _assert(not rule.endswith('.js'), | 267 _assert(not rule.endswith('.js'), |
257 ".js extension must not be used in rule keys.") | 268 ".js extension must not be used in rule keys.") |
| 269 if basename in JS_TEST_PATHS and '*' not in rule: |
| 270 _assert(any(os.path.exists(os.path.join(os.path.dirname(path), |
| 271 *(paths + [rule + ".js"]))) |
| 272 for paths in JS_TEST_PATHS[basename]), |
| 273 "missing file for %s test %s" % (basename, rule)) |
258 return status["success"] | 274 return status["success"] |
259 except Exception as e: | 275 except Exception as e: |
260 print e | 276 print e |
261 return False | 277 return False |
OLD | NEW |