mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
codegen: Verify that we're generating valid XML
We should output valid XML even when getting an iffy annotation.
This commit is contained in:
parent
17f38affa2
commit
47ce6432f3
@ -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())
|
||||||
|
Loading…
Reference in New Issue
Block a user