summaryrefslogtreecommitdiff
path: root/tests/test_domain_c.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-10 00:32:26 +0900
committerGitHub <noreply@github.com>2021-04-10 00:32:26 +0900
commitfe6d95e4294f47d61f1a04a1f8c6567c9802f504 (patch)
tree33a7143bf1dcf60830c2e1fcd4b396175af45e64 /tests/test_domain_c.py
parent7327e56dff865d4766c43d46405ae827e10fd6c3 (diff)
parentce5d66e618c111b115a9bb7b1401a26483fcfa8f (diff)
downloadsphinx-git-fe6d95e4294f47d61f1a04a1f8c6567c9802f504.tar.gz
Merge branch 'master' into patch-1
Diffstat (limited to 'tests/test_domain_c.py')
-rw-r--r--tests/test_domain_c.py41
1 files changed, 34 insertions, 7 deletions
diff --git a/tests/test_domain_c.py b/tests/test_domain_c.py
index 2cfcf74fa..ef4858786 100644
--- a/tests/test_domain_c.py
+++ b/tests/test_domain_c.py
@@ -417,6 +417,12 @@ def test_function_definitions():
check('function', 'void f(int arr[const static volatile 42])', {1: 'f'},
output='void f(int arr[static volatile const 42])')
+ with pytest.raises(DefinitionError):
+ parse('function', 'void f(int for)')
+
+ # from #8960
+ check('function', 'void f(void (*p)(int, double), int i)', {1: 'f'})
+
def test_nested_name():
check('struct', '{key}.A', {1: "A"})
@@ -523,8 +529,15 @@ def test_attributes():
# raise DefinitionError("")
+def split_warnigns(warning):
+ ws = warning.getvalue().split("\n")
+ assert len(ws) >= 1
+ assert ws[-1] == ""
+ return ws[:-1]
+
+
def filter_warnings(warning, file):
- lines = warning.getvalue().split("\n")
+ lines = split_warnigns(warning)
res = [l for l in lines if "domain-c" in l and "{}.rst".format(file) in l and
"WARNING: document isn't included in any toctree" not in l]
print("Filtered warnings for file '{}':".format(file))
@@ -578,10 +591,22 @@ def test_build_domain_c_anon_dup_decl(app, status, warning):
assert "WARNING: c:identifier reference target not found: @b" in ws[1]
-@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
-def test_build_domain_c_semicolon(app, status, warning):
- app.builder.build_all()
- ws = filter_warnings(warning, "semicolon")
+@pytest.mark.sphinx(confoverrides={'nitpicky': True})
+def test_build_domain_c_semicolon(app, warning):
+ text = """
+.. c:member:: int member;
+.. c:var:: int var;
+.. c:function:: void f();
+.. .. c:macro:: NO_SEMICOLON;
+.. c:struct:: Struct;
+.. c:union:: Union;
+.. c:enum:: Enum;
+.. c:enumerator:: Enumerator;
+.. c:type:: Type;
+.. c:type:: int TypeDef;
+"""
+ restructuredtext.parse(app, text)
+ ws = split_warnigns(warning)
assert len(ws) == 0
@@ -593,8 +618,8 @@ def test_build_function_param_target(app, warning):
assert len(ws) == 0
entries = extract_role_links(app, "function_param_target.html")
assert entries == [
- ('c.f', 'i', 'i'),
- ('c.f', 'f.i', 'f.i'),
+ ('c.function_param_target.f', 'i', 'i'),
+ ('c.function_param_target.f', 'f.i', 'f.i'),
]
@@ -656,6 +681,8 @@ def test_noindexentry(app):
@pytest.mark.sphinx(testroot='domain-c-intersphinx', confoverrides={'nitpicky': True})
def test_intersphinx(tempdir, app, status, warning):
+ # a splitting of test_ids_vs_tags0 into the primary directives in a remote project,
+ # and then the references in the test project
origSource = """\
.. c:member:: int _member
.. c:var:: int _var