[glib/ebassi/issue-2601] codegen: Verify that we're generating valid XML



commit 47ce6432f32455af1902996b05055c76e839d406
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Feb 15 12:14:49 2022 +0000

    codegen: Verify that we're generating valid XML
    
    We should output valid XML even when getting an iffy annotation.

 gio/tests/codegen.py | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/gio/tests/codegen.py b/gio/tests/codegen.py
index c95736e39..93508fa62 100644
--- a/gio/tests/codegen.py
+++ b/gio/tests/codegen.py
@@ -27,10 +27,10 @@ import subprocess
 import sys
 import tempfile
 import unittest
+import xml.etree.ElementTree as ET
 
 import taptestrunner
 
-
 # Disable line length warnings as wrapping the C code templates would be hard
 # 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("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__":
     unittest.main(testRunner=taptestrunner.TAPTestRunner())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]