As reported here:
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655434.html
the schema validation I added for generated .sarif files in
r15-1541-ga84fe222029ff2 used the "jsonschema" command line tool, which
has been deprecated by more recent versions of the Python 3 "jsonschema"
module.
This patch updates the validation to use the more recent
"check-jsonschema" command line tool, from the Python 3 "check-jsonschema"
module, fixing the testsuite FAILs due to the deprecation message.
As an added bonus, the output on validation failures is *much* nicer, e.g.
if I undo
r15-1540-g9f4fdc3acebcf6, the error messages begin like this:
verify-sarif-file: res: Schema validation errors were encountered.
diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].locations[0].physicalLocation.region.startColumn: 0 is less than the minimum of 1
diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[0].physicalLocation.region.startColumn: 0 is less than the minimum of 1
diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[1].physicalLocation.region.startColumn: 0 is less than the minimum of 1
diagnostic-format-sarif-file-bad-utf8-pr109098-1.c.sarif::$.runs[0].results[0].relatedLocations[2].physicalLocation.region.startColumn: 0 is less than the minimum of 1
child process exited abnormally
FAIL: c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-1.c -Wc++-compat (test .sarif output against SARIF schema)
Tested with Python 3.8 with check_jsonschema 0.28.6
gcc/ChangeLog:
PR testsuite/109360
* doc/install.texi (Python3 modules): Update SARIF validation
requirement to use check-jsonschema rather than jsonschema.
gcc/testsuite/ChangeLog:
PR testsuite/109360
* lib/scansarif.exp (verify-sarif-file): Use check-jsonschema
rather than jsonschema, updating the invocation accordingly.
* lib/target-supports.exp (check_effective_target_jsonschema): Convert
to...
(check_effective_target_check_jsonschema): ...this.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
@code{gcov}, @code{gzip}, @code{json}, @code{os} and @code{pytest}.
@item SARIF testsuite
-Tests of SARIF output will use the @code{jsonschema} program from the
-@code{jsonschema} module (if available) to validate generated .sarif files.
-If this tool is not found, the validation parts of those tests are skipped.
+Tests of SARIF output will use the @code{check-jsonschema} program from
+the @code{check-jsonschema} module (if available) to validate generated
+.sarif files. If this tool is not found, the validation parts of those
+tests are skipped.
@item c++ cxx api generation
@code{csv}, @code{os}, @code{sys} and @code{time}.
# Assuming python3 is available, use verify-sarif-file.py to check
# that the .sarif file is UTF-8 encoded and is parseable as JSON.
#
-# Assuming "jsonschema" is available, use it to verify that the .sarif
+# Assuming "check-jsonschema" is available, use it to verify that the .sarif
# file complies with the SARIF schema.
proc verify-sarif-file { args } {
# Verify that the file complies with the SARIF schema.
# Check that jsonschema is installed.
- if { ![check_effective_target_jsonschema] } {
- unsupported "$testcase verify-sarif-file: jsonschema is missing"
+ if { ![check_effective_target_check_jsonschema] } {
+ unsupported "$testcase verify-sarif-file: check-jsonschema is missing"
return
}
verbose "schema_file: $schema_file" 2
set what "$testcase (test .sarif output against SARIF schema)"
- if [catch {exec jsonschema --instance $output_file $schema_file} res ] {
+ if [catch {exec check-jsonschema --schemafile $schema_file $output_file} res ] {
verbose "verify-sarif-file: res: $res" 2
fail "$what"
return
return 0
}
-# Return 1 if jsonschema is available.
+# Return 1 if check-jsonschema is available.
-proc check_effective_target_jsonschema { } {
- set result [remote_exec host "jsonschema --version"]
+proc check_effective_target_check_jsonschema { } {
+ set result [remote_exec host "check-jsonschema --version"]
set status [lindex $result 0]
if { $status == 0 } then {
return 1;