mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 20:22:11 +01:00
tests: Add tests for gdbus-codegen generated RST
Those tests check if methods, signals and properties documentation are properly generated.
This commit is contained in:
parent
9a4e54e1b7
commit
605be9a1e9
@ -520,6 +520,123 @@ G_END_DECLS
|
|||||||
rst = f.readlines()
|
rst = f.readlines()
|
||||||
self.assertTrue(len(rst) != 0)
|
self.assertTrue(len(rst) != 0)
|
||||||
|
|
||||||
|
def test_generate_rst_method(self):
|
||||||
|
"""Test generating a method documentation with the rst generator."""
|
||||||
|
xml_contents = """
|
||||||
|
<node>
|
||||||
|
<interface name="org.project.Bar.Frobnicator">
|
||||||
|
<!-- RandomMethod:
|
||||||
|
|
||||||
|
A random test method.
|
||||||
|
-->
|
||||||
|
<method name="RandomMethod"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
"""
|
||||||
|
res = self.runCodegenWithInterface(
|
||||||
|
xml_contents,
|
||||||
|
"--generate-rst",
|
||||||
|
"test",
|
||||||
|
)
|
||||||
|
self.assertEqual("", res.err)
|
||||||
|
self.assertEqual("", res.out)
|
||||||
|
with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
|
||||||
|
rst = f.read()
|
||||||
|
self.assertIn("""
|
||||||
|
-------
|
||||||
|
Methods
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. _org.project.Bar.Frobnicator.RandomMethod:
|
||||||
|
|
||||||
|
org.project.Bar.Frobnicator.RandomMethod
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
RandomMethod ()
|
||||||
|
|
||||||
|
|
||||||
|
A random test method.""", rst)
|
||||||
|
|
||||||
|
def test_generate_rst_signal(self):
|
||||||
|
"""Test generating a signal documentation with the rst generator."""
|
||||||
|
xml_contents = """
|
||||||
|
<node>
|
||||||
|
<interface name="org.project.Bar.Frobnicator">
|
||||||
|
<!-- RandomSignal:
|
||||||
|
|
||||||
|
A random test signal.
|
||||||
|
-->
|
||||||
|
<signal name="RandomSignal"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
"""
|
||||||
|
res = self.runCodegenWithInterface(
|
||||||
|
xml_contents,
|
||||||
|
"--generate-rst",
|
||||||
|
"test",
|
||||||
|
)
|
||||||
|
self.assertEqual("", res.err)
|
||||||
|
self.assertEqual("", res.out)
|
||||||
|
with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
|
||||||
|
rst = f.read()
|
||||||
|
self.assertIn("""
|
||||||
|
-------
|
||||||
|
Signals
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. _org.project.Bar.Frobnicator::RandomSignal:
|
||||||
|
|
||||||
|
org.project.Bar.Frobnicator::RandomSignal
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
RandomSignal ()
|
||||||
|
|
||||||
|
|
||||||
|
A random test signal.""", rst)
|
||||||
|
|
||||||
|
def test_generate_rst_property(self):
|
||||||
|
"""Test generating a property documentation with the rst generator."""
|
||||||
|
xml_contents = """
|
||||||
|
<node>
|
||||||
|
<interface name="org.project.Bar.Frobnicator">
|
||||||
|
<!-- RandomProperty:
|
||||||
|
|
||||||
|
A random test property.
|
||||||
|
-->
|
||||||
|
<property type="s" name="RandomProperty" access="read"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
"""
|
||||||
|
res = self.runCodegenWithInterface(
|
||||||
|
xml_contents,
|
||||||
|
"--generate-rst",
|
||||||
|
"test",
|
||||||
|
)
|
||||||
|
self.assertEqual("", res.err)
|
||||||
|
self.assertEqual("", res.out)
|
||||||
|
with open("test-org.project.Bar.Frobnicator.rst", "r") as f:
|
||||||
|
rst = f.read()
|
||||||
|
self.assertIn("""
|
||||||
|
----------
|
||||||
|
Properties
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. _org.project.Bar.Frobnicator:RandomProperty:
|
||||||
|
|
||||||
|
org.project.Bar.Frobnicator:RandomProperty
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
RandomProperty readable s
|
||||||
|
|
||||||
|
|
||||||
|
A random test property.""", rst)
|
||||||
|
|
||||||
@unittest.skipIf(on_win32(), "requires /dev/stdout")
|
@unittest.skipIf(on_win32(), "requires /dev/stdout")
|
||||||
def test_glib_min_required_invalid(self):
|
def test_glib_min_required_invalid(self):
|
||||||
"""Test running with an invalid --glib-min-required."""
|
"""Test running with an invalid --glib-min-required."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user