blob: 8687168e88410ea70aa58e57d577ba86b80a7170 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# Verify that basics of HTML output work.
#
# For reference, we expect this textual output:
#
# PATH/missing-semicolon.c: In function ‘missing_semicolon’:
# PATH/missing-semicolon.c:8:12: error: expected ‘;’ before ‘}’ token
# 8 | return 42 /* { dg-error "expected ';' before '.' token" } */
# | ^
# | ;
# 9 | }
# | ~
from htmltest import *
import pytest
@pytest.fixture(scope='function', autouse=True)
def html_tree():
return html_tree_from_env()
XHTML = 'http://www.w3.org/1999/xhtml'
ns = {'xhtml': XHTML}
def make_tag(local_name):
return f'{{{XHTML}}}' + local_name
def test_basics(html_tree):
root = html_tree.getroot ()
assert root.tag == make_tag('html')
head = root.find('xhtml:head', ns)
assert head is not None
title = head.find('xhtml:title', ns)
assert title.text == 'Title goes here'
body = root.find('xhtml:body', ns)
assert body is not None
diag_list = body.find('xhtml:div', ns)
assert diag_list is not None
assert diag_list.attrib['class'] == 'gcc-diagnostic-list'
diag = diag_list.find('xhtml:div', ns)
assert diag is not None
assert diag.attrib['class'] == 'gcc-diagnostic'
message = diag.find('xhtml:span', ns)
assert message is not None
assert message.attrib['class'] == 'gcc-message'
assert message.text == "expected '"
assert message[0].tag == make_tag('span')
assert message[0].attrib['class'] == 'gcc-quoted-text'
assert message[0].text == ';'
assert message[0].tail == "' before '"
assert message[1].tag == make_tag('span')
assert message[1].attrib['class'] == 'gcc-quoted-text'
assert message[1].text == '}'
assert message[1].tail == "' token"
pre = diag.find('xhtml:pre', ns)
assert pre is not None
assert pre.attrib['class'] == 'gcc-annotated-source'
# For reference, here's the generated HTML:
"""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title goes here</title>
</head>
<body>
<div class="gcc-diagnostic-list">
<div class="gcc-diagnostic">
<span class="gcc-message">expected '<span class="gcc-quoted-text">;</span>' before '<span class="gcc-quoted-text">}</span>' token</span>
<pre class="gcc-annotated-source"></pre>
</div>
</div>
</body>
</html>
"""
|