Skip to content

Commit ada1b8c

Browse files
committed
Validate JSON build output against schema.
1 parent 67c2f2c commit ada1b8c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"python3": "==3.8.10",
4040
"pip:pylint": "==2.4.4",
4141
"pip:lazy-object-proxy": "==1.6.0",
42-
"pip:ninja_syntax": "==1.7.2"
42+
"pip:ninja_syntax": "==1.7.2",
43+
"pip:jsonschema": "==4.6.1"
4344
},
4445
"python_version": "3"
4546
},

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
from mx_gate import Task
5454
from mx_unittest import _run_tests, _VMLauncher
5555

56+
import json
57+
from jsonschema import validate as json_validate
58+
5659
import sys
5760

5861
if sys.version_info[0] < 3:
@@ -356,6 +359,16 @@ def svm_gate_body(args, tasks):
356359
if t:
357360
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
358361
image_demo_task()
362+
363+
with Task('image demos json build output', tasks, tags=[GraalTags.helloworld]) as t:
364+
if t:
365+
with open(join(suite.dir, '..', 'docs', 'reference-manual', 'native-image', 'assets', 'build-output-schema-v0.9.0.json')) as f:
366+
json_schema = json.load(f)
367+
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
368+
with tempfile.NamedTemporaryFile(prefix="build_json") as json_file:
369+
image_demo_task(['-H:BuildOutputJSONFile', json_file.name])
370+
if not json_validate(json.load(json_file),json_schema):
371+
mx.abort('JSON build output did not validate against the schema.')
359372

360373
with Task('image demos debuginfo', tasks, tags=[GraalTags.helloworld_debug]) as t:
361374
if t:

0 commit comments

Comments
 (0)