| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if rule[-1] == '*': | 149 if rule[-1] == '*': |
| 150 _ParseOutcomeList(rule, section[rule], wildcards, variables) | 150 _ParseOutcomeList(rule, section[rule], wildcards, variables) |
| 151 else: | 151 else: |
| 152 _ParseOutcomeList(rule, section[rule], rules, variables) | 152 _ParseOutcomeList(rule, section[rule], rules, variables) |
| 153 return rules, wildcards | 153 return rules, wildcards |
| 154 | 154 |
| 155 | 155 |
| 156 def PresubmitCheck(path): | 156 def PresubmitCheck(path): |
| 157 contents = ReadContent(path) | 157 contents = ReadContent(path) |
| 158 root_prefix = os.path.basename(os.path.dirname(path)) + "/" | 158 root_prefix = os.path.basename(os.path.dirname(path)) + "/" |
| 159 | 159 status = {"success": True} |
| 160 def _assert(check, message): # Like "assert", but doesn't throw. |
| 161 if not check: |
| 162 print("%s: Error: %s" % (path, message)) |
| 163 status["success"] = False |
| 160 try: | 164 try: |
| 161 for section in contents: | 165 for section in contents: |
| 162 assert type(section) == list | 166 _assert(type(section) == list, "Section must be a list") |
| 163 assert len(section) == 2 | 167 _assert(len(section) == 2, "Section list must have exactly 2 entries") |
| 164 section = section[1] | 168 section = section[1] |
| 165 assert type(section) == dict | 169 _assert(type(section) == dict, |
| 170 "Second entry of section must be a dictionary") |
| 166 for rule in section: | 171 for rule in section: |
| 167 assert type(rule) == str | 172 _assert(type(rule) == str, "Rule key must be a string") |
| 168 assert not rule.startswith(root_prefix), ( | 173 _assert(not rule.startswith(root_prefix), |
| 169 "Suite name prefix must not be used in status files") | 174 "Suite name prefix must not be used in rule keys") |
| 170 assert not rule.endswith('.js'), ( | 175 _assert(not rule.endswith('.js'), |
| 171 ".js extension must not be used in status files.") | 176 ".js extension must not be used in rule keys.") |
| 172 return True | 177 return status["success"] |
| 173 except Exception as e: | 178 except Exception as e: |
| 174 print e | 179 print e |
| 175 return False | 180 return False |
| OLD | NEW |