Chromium Code Reviews| 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 def _Assert(check, message, status): | |
|
Michael Achenbach
2015/11/27 14:24:20
nit: naming (optional). Since it's nested, the _ i
Jakob Kummerow
2015/11/27 14:43:26
Compromise: _assert (to emphasize that it's a cust
| |
| 160 if not check: | |
| 161 print("%s: Error: %s" % (path, message)) | |
| 162 status["success"] = False | |
| 159 | 163 |
| 164 status = {"success": True} | |
|
Michael Achenbach
2015/11/27 14:24:20
As talked offline. You could move this a few lines
Jakob Kummerow
2015/11/27 14:43:26
Done.
| |
| 160 try: | 165 try: |
| 161 for section in contents: | 166 for section in contents: |
| 162 assert type(section) == list | 167 _Assert(type(section) == list, "Section must be a list", status) |
|
Michael Achenbach
2015/11/27 14:24:20
Just for the record. Also as discussed offline. If
Jakob Kummerow
2015/11/27 14:43:26
Keeping as is, reasoning: it's rather unlikely tha
| |
| 163 assert len(section) == 2 | 168 _Assert(len(section) == 2, "Section list must have exactly 2 entries", |
| 169 status) | |
| 164 section = section[1] | 170 section = section[1] |
| 165 assert type(section) == dict | 171 _Assert(type(section) == dict, |
| 172 "Second entry of section must be a dictionary", status) | |
| 166 for rule in section: | 173 for rule in section: |
| 167 assert type(rule) == str | 174 _Assert(type(rule) == str, "Rule key must be a string", status) |
| 168 assert not rule.startswith(root_prefix), ( | 175 _Assert(not rule.startswith(root_prefix), |
| 169 "Suite name prefix must not be used in status files") | 176 "Suite name prefix must not be used in rule keys", status) |
| 170 assert not rule.endswith('.js'), ( | 177 _Assert(not rule.endswith('.js'), |
| 171 ".js extension must not be used in status files.") | 178 ".js extension must not be used in rule keys.", status) |
| 172 return True | 179 return status["success"] |
| 173 except Exception as e: | 180 except Exception as e: |
| 174 print e | 181 print e |
| 175 return False | 182 return False |
| OLD | NEW |