codegen: Verify that we're generating valid XML

We should output valid XML even when getting an iffy annotation.
This commit is contained in:
Emmanuele Bassi 2022-02-15 12:14:49 +00:00
parent 17f38affa2
commit 47ce6432f3

View File

@ -27,10 +27,10 @@ import subprocess
import sys import sys
import tempfile import tempfile
import unittest import unittest
import xml.etree.ElementTree as ET
import taptestrunner import taptestrunner
# Disable line length warnings as wrapping the C code templates would be hard # Disable line length warnings as wrapping the C code templates would be hard
# flake8: noqa: E501 # flake8: noqa: E501
@ -625,6 +625,40 @@ G_END_DECLS
self.assertEqual(result.out.strip().count("GDBusCallFlags call_flags,"), 2) self.assertEqual(result.out.strip().count("GDBusCallFlags call_flags,"), 2)
self.assertEqual(result.out.strip().count("gint timeout_msec,"), 2) self.assertEqual(result.out.strip().count("gint timeout_msec,"), 2)
def test_generate_valid_docbook(self):
"""Test the basic functionality of the docbook generator."""
xml_contents = """
<node>
<interface name="org.project.Bar.Frobnicator">
<!-- Resize:
@size: New partition size in bytes, 0 for maximal size.
@options: Options.
@since 2.7.2
Resizes the partition.
The partition will not change its position but might be slightly bigger
than requested due to sector counts and alignment (e.g. 1MiB).
If the requested size can't be allocated it results in an error.
The maximal size can automatically be set by using 0 as size.
-->
<method name="Resize">
<arg name="size" direction="in" type="t"/>
<arg name="options" direction="in" type="a{sv}"/>
</method>
</interface>
</node>
"""
res = self.runCodegenWithInterface(
xml_contents,
"--generate-docbook",
"test",
)
self.assertEqual("", res.err)
self.assertEqual("", res.out)
with open("test-org.project.Bar.Frobnicator.xml", "r") as f:
self.assertTrue(ET.parse(f) is not None)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(testRunner=taptestrunner.TAPTestRunner()) unittest.main(testRunner=taptestrunner.TAPTestRunner())