Index: tools/testrunner/local/statusfile.py |
diff --git a/tools/testrunner/local/statusfile.py b/tools/testrunner/local/statusfile.py |
index 6e2a012a9aa0795a0f1a1a812fbc5dfaaead0185..6e66a72b951a552f42e5edb1bcfd12a5871ff9f9 100644 |
--- a/tools/testrunner/local/statusfile.py |
+++ b/tools/testrunner/local/statusfile.py |
@@ -156,20 +156,27 @@ def ReadStatusFile(path, variables): |
def PresubmitCheck(path): |
contents = ReadContent(path) |
root_prefix = os.path.basename(os.path.dirname(path)) + "/" |
+ 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
|
+ if not check: |
+ print("%s: Error: %s" % (path, message)) |
+ status["success"] = False |
+ 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.
|
try: |
for section in contents: |
- assert type(section) == list |
- assert len(section) == 2 |
+ _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
|
+ _Assert(len(section) == 2, "Section list must have exactly 2 entries", |
+ status) |
section = section[1] |
- assert type(section) == dict |
+ _Assert(type(section) == dict, |
+ "Second entry of section must be a dictionary", status) |
for rule in section: |
- assert type(rule) == str |
- assert not rule.startswith(root_prefix), ( |
- "Suite name prefix must not be used in status files") |
- assert not rule.endswith('.js'), ( |
- ".js extension must not be used in status files.") |
- return True |
+ _Assert(type(rule) == str, "Rule key must be a string", status) |
+ _Assert(not rule.startswith(root_prefix), |
+ "Suite name prefix must not be used in rule keys", status) |
+ _Assert(not rule.endswith('.js'), |
+ ".js extension must not be used in rule keys.", status) |
+ return status["success"] |
except Exception as e: |
print e |
return False |