[jhbuild] cmake: fix xml serialization



commit 92b9aeb7ba98257484bd0d49f4249c32cafe31b5
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Sep 23 09:57:08 2019 +0200

    cmake: fix xml serialization
    
    The python attr name was missing for cmakedir which made snapshot crash.
    Fix it and add a test.

 jhbuild/modtypes/__init__.py |  2 ++
 jhbuild/modtypes/cmake.py    |  2 +-
 tests/test_main.py           | 13 ++++++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 48619f94..2919a9f9 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -495,6 +495,8 @@ them into the prefix."""
 
     def branch_to_sxml(self):
         """Serialize this module's checkout branch as sxml."""
+        if self.branch is None:
+            return [sxml.branch]
         return self.branch.to_sxml()
 
     @classmethod
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 8ea59cf1..1bd44e32 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -153,7 +153,7 @@ class CMakeModule(MakeModule, NinjaModule, DownloadableModule):
         return 'cmake', [('id', 'name', None),
                          ('skip-install', 'skip_install_phase', False),
                          ('use-ninja', 'use_ninja', True),
-                         ('cmakedir', None),
+                         ('cmakedir', 'cmakedir', None),
                          ('supports-non-srcdir-builds',
                           'supports_non_srcdir_builds', True),
                          ('force-non-srcdir-builds',
diff --git a/tests/test_main.py b/tests/test_main.py
index 680b5a16..3ada3085 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -54,6 +54,7 @@ import jhbuild.frontends.terminal
 import jhbuild.moduleset
 import jhbuild.utils.cmds
 import jhbuild.versioncontrol.tarball
+from jhbuild.utils.sxml import sxml_to_string
 
 from . import mock
 
@@ -183,7 +184,17 @@ class JhbuildConfigTestCase(unittest.TestCase):
         module_set.packagedb = mock.PackageDB()
         return jhbuild.frontends.terminal.TerminalBuildScript(config, module_list, module_set)
 
-    
+
+class CMakeModuleTest(unittest.TestCase):
+
+    def test_to_sxml(self):
+        from jhbuild.modtypes.cmake import CMakeModule
+
+        mod = CMakeModule("foo")
+        self.assertEqual(
+            sxml_to_string(mod.to_sxml()),
+            '<cmake id="foo"><dependencies></dependencies>\n<branch></branch></cmake>')
+
 
 class ModuleOrderingTestCase(JhbuildConfigTestCase):
     '''Module Ordering'''


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