]> git.ipfire.org Git - thirdparty/gcc.git/commit
diagnostics: convert HTML output test plugin to 'experimental-html' sink [PR116792]
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 9 May 2025 00:41:35 +0000 (20:41 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 9 May 2025 00:41:35 +0000 (20:41 -0400)
commit1a2c62212bd912f5c8130e992ce282b542599f98
tree09684c2d1f8d051caf2af9dda4cdd88618dbcd50
parent8dba9c7ec97ef6e5e891c77a0f0d536860172beb
diagnostics: convert HTML output test plugin to 'experimental-html' sink [PR116792]

In r15-3752-g48261bd26df624 I added a test plugin that overrode the
regular output, instead emitting diagnostics in crude HTML form.

In r15-4760-g0b73e9382ab51c I added support for multiple kinds of
diagnostic output simultaneously, adding
 -fdiagnostics-add-output=DIAGNOSTICS-OUTPUT-SPEC
 -fdiagnostics-set-output=DIAGNOSTICS-OUTPUT-SPEC
for adding/changing the kind of diagnostics output, supporting
"text" and "sarif" output schemes.

This patch promotes the HTML output code from the test plugins so
that it is available from "-fdiagnostics-add-output=", using a
new "experimental-html" scheme, to allow simultaneous text, sarif
and html output, and to make it easier to experiment with.  The
patch adds Python-based testing of the emitted HTML.

The patch does not affect the generated HTML, which is still crude, and
not yet ready for end-users.  I hope to improve it in followups.

gcc/ChangeLog:
PR other/116792
* Makefile.in (OBJS-libcommon): Add diagnostic-format-html.o.
* diagnostic-format-html.cc: Move here from
testsuite/gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc.
Simplify includes.  Rename "xhtml" to "html" throughout.
(write_escaped_text): Drop.
(class xhtml_stream_output_format): Drop.
(class html_file_output_format): Reimplement using
diagnostic_output_file.
(diagnostic_output_format_init_xhtml): Drop.
(diagnostic_output_format_init_xhtml_stderr): Drop.
(diagnostic_output_format_init_xhtml_file): Drop.
(diagnostic_output_format_open_html_file): New.
(make_html_sink): New.
(xhtml_format_selftests): Convert to...
(diagnostic_format_html_cc_tests): ...this.
(plugin_is_GPL_compatible): Drop.
(plugin_init): Drop.
* diagnostic-format-html.h: New file.
* doc/invoke.texi (-fdiagnostics-add-output=): Add
"experimental-html" scheme.
* opts-diagnostic.cc: Include "diagnostic-format-html.h".
(class html_scheme_handler): New.
(output_factory::output_factory): Add html_scheme_handler.
(html_scheme_handler::make_sink): New.
* selftest-run-tests.cc (selftest::run_tests): Call the new
selftests.
* selftest.h (selftest::diagnostic_format_html_cc_tests): New
decl.

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Move to
gcc/diagnostic-format-html.cc.
* gcc.dg/html-output/html-output.exp: New support script.
* gcc.dg/html-output/missing-semicolon.c: New test.
* gcc.dg/html-output/missing-semicolon.py: New test script.
* gcc.dg/plugin/diagnostic-test-xhtml-1.c: Deleted test.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Drop moved plugin
and its deleted test.
* lib/gcc-dg.exp (load_lib): Add load_lib of scanhtml.exp.
* lib/htmltest.py: New support script.
* lib/scanhtml.exp: New support script, based on scansarif.exp.

libatomic/ChangeLog:
PR other/116792
* testsuite/lib/libatomic.exp: Add load_lib of scanhtml.exp.

libgomp/ChangeLog:
PR other/116792
* testsuite/lib/libgomp.exp: Add load_lib of scanhtml.exp.

libitm/ChangeLog:
PR other/116792
* testsuite/lib/libitm.exp: Add load_lib of scanhtml.exp.

libphobos/ChangeLog:
PR other/116792
* testsuite/lib/libphobos-dg.exp: Add load_lib of scanhtml.exp.

libvtv/ChangeLog:
PR other/116792
* testsuite/lib/libvtv-dg.exp: Add load_lib of scanhtml.exp.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
20 files changed:
gcc/Makefile.in
gcc/diagnostic-format-html.cc [moved from gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc with 72% similarity]
gcc/diagnostic-format-html.h [new file with mode: 0644]
gcc/doc/invoke.texi
gcc/opts-diagnostic.cc
gcc/selftest-run-tests.cc
gcc/selftest.h
gcc/testsuite/gcc.dg/html-output/html-output.exp [new file with mode: 0644]
gcc/testsuite/gcc.dg/html-output/missing-semicolon.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/html-output/missing-semicolon.py [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/diagnostic-test-xhtml-1.c [deleted file]
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/htmltest.py [new file with mode: 0644]
gcc/testsuite/lib/scanhtml.exp [new file with mode: 0644]
libatomic/testsuite/lib/libatomic.exp
libgomp/testsuite/lib/libgomp.exp
libitm/testsuite/lib/libitm.exp
libphobos/testsuite/lib/libphobos-dg.exp
libvtv/testsuite/lib/libvtv-dg.exp