aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-07-24 18:07:56 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-07-24 18:07:56 -0400
commit68c7747dd29016d51e6f04e7fe1d8543423f093f (patch)
tree9702dd377ea477c6830328686ac018d9f11c4651 /libcpp
parentd7a688fc960f78c62aacdc5acb8432873fed300e (diff)
downloadgcc-68c7747dd29016d51e6f04e7fe1d8543423f093f.zip
gcc-68c7747dd29016d51e6f04e7fe1d8543423f093f.tar.gz
gcc-68c7747dd29016d51e6f04e7fe1d8543423f093f.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