aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
authorEverett Hildenbrandt <hildenb2@illinois.edu>2018-05-31 02:37:29 +0800
committerEverett Hildenbrandt <hildenb2@illinois.edu>2018-05-31 22:37:30 +0800
commit6946875d23ea86d42e3cf1bdc06df536c88c0f4e (patch)
tree66291a72f9fe8748e6f086e160cc3bb46d17aed2 /test.py
parent2753667b68af77e59b6f89cbc16a8942455e7633 (diff)
downloaddexon-tests-6946875d23ea86d42e3cf1bdc06df536c88c0f4e.tar.gz
dexon-tests-6946875d23ea86d42e3cf1bdc06df536c88c0f4e.tar.zst
dexon-tests-6946875d23ea86d42e3cf1bdc06df536c88c0f4e.zip
test.py: execute through errors, reprint errors together at end
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/test.py b/test.py
index 45c0fb321..28a0670b8 100755
--- a/test.py
+++ b/test.py
@@ -36,9 +36,18 @@ import os
import json
import jsonschema
+exit_status = 0
+error_log = []
+
def _report(*msg):
print("== " + sys.argv[0] + ":", *msg, file=sys.stderr)
+def _logerror(*msg):
+ global exit_status
+ _report("ERROR:", *msg)
+ error_log.append(" ".join(msg))
+ exit_status = 1
+
def _die(*msg, exit_code=1):
_report(*msg)
_report("exiting...")
@@ -78,23 +87,28 @@ def validateSchema(jsonFile, schemaFile):
}
jsonInput = readJSONFile(jsonFile)
- jsonschema.validate(jsonInput, schema)
+ try:
+ jsonschema.validate(jsonInput, schema)
+ except:
+ _logerror("Validation failed:", "schema", schemaFile, "on", jsonFile)
def validateTestFile(jsonFile):
if jsonFile.startswith("./src/VMTestsFiller/"):
- validateSchema(jsonFile, "JSONSchema/vm-filler-schema.json")
+ schemaFile = "JSONSchema/vm-filler-schema.json"
elif jsonFile.startswith("./src/GeneralStateTestsFiller/"):
- validateSchema(jsonFile, "JSONSchema/st-filler-schema.json")
+ schemaFile = "JSONSchema/st-filler-schema.json"
elif jsonFile.startswith("./src/BlockchainTestsFiller/"):
- validateSchema(jsonFile, "JSONSchema/bc-filler-schema.json")
+ schemaFile = "JSONSchema/bc-filler-schema.json"
elif jsonFile.startswith("./VMTests/"):
- validateSchema(jsonFile, "JSONSchema/vm-schema.json")
+ schemaFile = "JSONSchema/vm-schema.json"
elif jsonFile.startswith("./GeneralStateTests/"):
- validateSchema(jsonFile, "JSONSchema/st-schema.json")
+ schemaFile = "JSONSchema/st-schema.json"
elif jsonFile.startswith("./BlockchainTests/"):
- validateSchema(jsonFile, "JSONSchema/bc-schema.json")
+ schemaFile = "JSONSchema/bc-schema.json"
else:
- _die("Do not know how to validate file:", jsonFile)
+ _logerror("Do not know how to validate file:", jsonFile)
+ return
+ validateSchema(jsonFile, schemaFile)
def _usage():
usage_lines = [ ""
@@ -133,5 +147,8 @@ def main():
_report(test_command + ":", test)
testDo(test)
+ if exit_status != 0:
+ _die("Errors reported!\n[ERROR] " + "\n[ERROR] ".join(error_log))
+
if __name__ == "__main__":
main()