diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-07-24 18:07:56 -0400 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2024-07-28 19:05:54 +0200 |
commit | e82aa0832a9ef222ce4a9340c2986019c168b8c0 (patch) | |
tree | 69c44e272b8b8b2092cf6518a137cfe5614416e7 /libcpp | |
parent | 4068969756b961ccf3f16ab8a07e788f600bee13 (diff) | |
download | gcc-e82aa0832a9ef222ce4a9340c2986019c168b8c0.zip gcc-e82aa0832a9ef222ce4a9340c2986019c168b8c0.tar.gz gcc-e82aa0832a9ef222ce4a9340c2986019c168b8c0.tar.bz2 |
diagnostics: add selftests for SARIF output
The existing DejaGnu-based tests for our SARIF output used regexes
to verify the JSON at the string level, which lets us test for
the presence of properties, but doesn't check the overall structure.
This patch uses the selftest framework to verify the structure of
the tree of JSON values for a log containing one diagnostic.
No functional change intended.
gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::flush_to_object):
New, using code moved from...
(sarif_builder::end_group): ...here.
(class selftest::test_sarif_diagnostic_context): New.
(selftest::test_simple_log): New.
(selftest::diagnostic_format_sarif_cc_tests): Call it.
* json.h (json::object::is_empty): New.
* selftest-diagnostic.cc (test_diagnostic_context::report): New.
* selftest-diagnostic.h (test_diagnostic_context::report): New
decl.
* selftest-json.cc (selftest::assert_json_string_eq): New.
(selftest::expect_json_object_with_string_property): New.
(selftest::assert_json_string_property_eq): New.
* selftest-json.h (selftest::assert_json_string_eq): New decl.
(ASSERT_JSON_STRING_EQ): New macro.
(selftest::expect_json_object_with_string_property): New decl.
(EXPECT_JSON_OBJECT_WITH_STRING_PROPERTY): New macro.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions