Skip to content
Snippets Groups Projects
Commit aa3b9502 authored by David Malcolm's avatar David Malcolm
Browse files

testsuite: generalize support for Python tests for SARIF output


In r15-2354-g4d1f71d49e396c I added the ability to use Python to write
tests of SARIF output via a new "run-sarif-pytest" based
on "run-gcov-pytest", with a sarif.py support script in
testsuite/gcc.dg/sarif-output.

This followup patch:
(a) removes the limitation of such tests needing to be in
testsuite/gcc.dg/sarif-output by moving sarif.py to testsuite/lib
and adding logic to add that directory to PYTHONPATH when invoking
pytest.

(b) uses this to replace fragile regexp-based tests in
gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.c with
Python logic that verifies the structure within the generated JSON,
and to add test coverage for SARIF output relating to GCC plugins.

gcc/ChangeLog:
	* diagnostic-format-sarif.cc: Add comments noting that we don't
	yet capture any diagnostic_metadata::rules associated with a
	diagnostic.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic-test-metadata-sarif.c: New test,
	based on diagnostic-test-metadata.c.
	* gcc.dg/plugin/diagnostic-test-metadata-sarif.py: New script.
	* gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.c:
	Replace scan-sarif-file directives with run-sarif-pytest, to
	run...
	* gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py:
	...this new test.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
	diagnostic-test-metadata-sarif.c.
	* gcc.dg/sarif-output/sarif.py: Move to...
	* lib/sarif.py: ...here.
	* lib/scansarif.exp (run-sarif-pytest): Prepend "lib" to
	PYTHONPATH before running python scripts.

Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent 276cc432
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment