diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/format')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/colors.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format/diagnostic-ranges-html.py | 79 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format/diagnostic-ranges.c | 6 |
3 files changed, 86 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/format/colors.c b/gcc/testsuite/gcc.dg/format/colors.c index 43484b7..42cfd50 100644 --- a/gcc/testsuite/gcc.dg/format/colors.c +++ b/gcc/testsuite/gcc.dg/format/colors.c @@ -15,8 +15,8 @@ void test_mismatching_types (const char *msg) warning: [m[Kformat '[01m[K[01;32m[K%i[m[K[m[K' expects argument of type '[01m[K[01;32m[Kint[m[K[m[K', but argument 2 has type '[01m[K[01;34m[Kconst char *[m[K[m[K' [[01;35m[K-Wformat=[m[K] { dg-end-multiline-output "" } */ /* { dg-begin-multiline-output "" } - printf("hello [01;32m[K%[m[K[01;32m[Ki[m[K", [01;34m[Km[m[K[01;34m[Ks[m[K[01;34m[Kg[m[K); - [01;32m[K~[m[K[01;32m[K^[m[K [01;34m[K~[m[K[01;34m[K~[m[K[01;34m[K~[m[K + printf("hello [01;32m[K%i[m[K", [01;34m[Kmsg[m[K); + [01;32m[K~^[m[K [01;34m[K~~~[m[K [01;32m[K|[m[K [01;34m[K|[m[K [01;32m[Kint[m[K [01;34m[Kconst char *[m[K [32m[K%s[m[K diff --git a/gcc/testsuite/gcc.dg/format/diagnostic-ranges-html.py b/gcc/testsuite/gcc.dg/format/diagnostic-ranges-html.py new file mode 100644 index 0000000..b0b59d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/diagnostic-ranges-html.py @@ -0,0 +1,79 @@ +from htmltest import * + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def html_tree(): + return html_tree_from_env() + +def assert_highlighted_text(element, expected_highlight, expected_text): + assert_tag(element, 'span') + assert_class(element, expected_highlight) + assert element.text == expected_text + +def test_message(html_tree): + """ + Verify that the quoted text in the message has the correct + highlight colors. + """ + diag = get_diag_by_index(html_tree, 0) + msg = get_message_within_diag(diag) + + assert_tag(msg[0], 'strong') + assert msg[0].text == 'warning: ' + + assert_tag(msg[1], 'span') + assert_class(msg[1], 'gcc-quoted-text') + assert_highlighted_text(msg[1][0], 'highlight-a', '%i') + + assert_tag(msg[2], 'span') + assert_class(msg[2], 'gcc-quoted-text') + assert_highlighted_text(msg[2][0], 'highlight-a', 'int') + + assert_tag(msg[3], 'span') + assert_class(msg[3], 'gcc-quoted-text') + assert_highlighted_text(msg[3][0], 'highlight-b', 'const char *') + +def test_annotations(html_tree): + """ + Verify that the labels in the annotations have the correct + highlight colors. + """ + diag = get_diag_by_index(html_tree, 0) + locus = get_locus_within_diag(diag) + tbody = locus.find('xhtml:tbody', ns) + assert tbody.attrib['class'] == 'line-span' + + rows = tbody.findall('xhtml:tr', ns) + + # Source row + row = rows[0] + tds = row.findall('xhtml:td', ns) + assert len(tds) == 2 + assert_class(tds[1], 'source') + assert_highlighted_text(tds[1][0], 'highlight-a', '%i') + assert_highlighted_text(tds[1][1], 'highlight-b', 'msg') + + # Underline row: + row = rows[1] + tds = row.findall('xhtml:td', ns) + assert len(tds) == 2 + assert_class(tds[1], 'annotation') + assert_highlighted_text(tds[1][0], 'highlight-a', '~^') + assert_highlighted_text(tds[1][1], 'highlight-b', '~~~') + + # vline row: + row = rows[2] + tds = row.findall('xhtml:td', ns) + assert len(tds) == 2 + assert_class(tds[1], 'annotation') + assert_highlighted_text(tds[1][0], 'highlight-a', '|') + assert_highlighted_text(tds[1][1], 'highlight-b', '|') + + # Label row: + row = rows[3] + tds = row.findall('xhtml:td', ns) + assert len(tds) == 2 + assert_class(tds[1], 'annotation') + assert_highlighted_text(tds[1][0], 'highlight-a', 'int') + assert_highlighted_text(tds[1][1], 'highlight-b', 'const char *') diff --git a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c index 2c33ce2..d3e334d 100644 --- a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c +++ b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c @@ -1,4 +1,4 @@ -/* { dg-options "-Wformat -fdiagnostics-show-caret" } */ +/* { dg-options "-Wformat -fdiagnostics-show-caret -fdiagnostics-add-output=experimental-html:javascript=no" } */ /* See PR 52952. */ @@ -390,3 +390,7 @@ void test_const_arrays (void) double { dg-end-multiline-output "" } */ } + +/* Use a Python script to verify various properties about the generated + HTML file: + { dg-final { run-html-pytest diagnostic-ranges.c "diagnostic-ranges-html.py" } } */ |