Fix build against libmodulemd-2.12

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2021-01-22 09:36:46 -05:00
parent fc96e27b57
commit 3a92ffc0d3
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11
3 changed files with 214 additions and 4 deletions

View File

@ -0,0 +1,130 @@
From 07847343ebab93d6a5b5f5311ed50f8525d43594 Mon Sep 17 00:00:00 2001
From: Jakub Kadlcik <frostyx@email.cz>
Date: Wed, 13 Jan 2021 01:37:35 +0100
Subject: [PATCH 1/2] modulemd_tools: quote stream fields in test suite
Somewhere between `python3-libmodulemd-2.11.1` and `python3-libmodulemd-2.9.3`
the `Modulemd.ModuleStream.read_string` or `Modulemd.ModuleStream.upgrade`
output changed and is now quoted, which breaks our tests:
- stream: "devel"
? - -
+ stream: devel
I can see those functions are deprecated now, so we will migrate to something
newer soon. This is just a temporary fix.
---
modulemd_tools/tests/test_yaml.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/modulemd_tools/tests/test_yaml.py b/modulemd_tools/tests/test_yaml.py
index 551b97d876d2e439a70492f5dec65622b8258880..ed5520cc86ded2e67994aa79ef8eeace9e7432ae 100644
--- a/modulemd_tools/tests/test_yaml.py
+++ b/modulemd_tools/tests/test_yaml.py
@@ -380,11 +380,11 @@ class TestYaml(unittest.TestCase):
yaml1 = """---
document: modulemd
version: 2
data:
name: foo
- stream: devel
+ stream: "devel"
version: 123
context: f32
summary: Summary and stuff
description: >-
This module has been generated using dir2module tool
@@ -413,11 +413,11 @@ data:
yaml2_invalid = """
---
document: modulemd
version: 2
data:
- stream: devel
+ stream: "devel"
version: 123
context: f32
summary: Summary and stuff
description: >-
This module has been generated using dir2module tool
@@ -444,11 +444,11 @@ yaml3_no_deps = """
---
document: modulemd
version: 2
data:
name: foo
- stream: devel
+ stream: "devel"
version: 123
context: f32
summary: Summary and stuff
description: >-
This module has been generated using dir2module tool
@@ -514,11 +514,11 @@ yaml5_multiple_streams = """
---
document: modulemd
version: 2
data:
name: foo
- stream: master
+ stream: "master"
version: 1
summary: A test module in all its beautiful beauty
description: >-
Some description
license:
@@ -528,11 +528,11 @@ data:
---
document: modulemd
version: 2
data:
name: foo
- stream: stable
+ stream: "stable"
version: 123
context: f32
summary: Summary and stuff
description: >-
This module has been generated using dir2module tool
@@ -548,11 +548,11 @@ yaml5_multiple_modules = """
---
document: modulemd
version: 2
data:
name: foo
- stream: master
+ stream: "master"
version: 1
summary: A test module in all its beautiful beauty
description: >-
Some description
license:
@@ -562,11 +562,11 @@ data:
---
document: modulemd
version: 2
data:
name: bar
- stream: stable
+ stream: "stable"
version: 123
context: f32
summary: Summary and stuff
description: >-
This module has been generated using dir2module tool
@@ -582,11 +582,11 @@ yaml6_multiple_pairs_of_deps = """
---
document: modulemd
version: 2
data:
name: foo
- stream: master
+ stream: "master"
version: 1
summary: A test module in all its beautiful beauty
description: >-
Some description
license:
--
2.29.2

View File

@ -0,0 +1,70 @@
From b6557cd10bdae6a839c56ef455020e82eb0e5988 Mon Sep 17 00:00:00 2001
From: Jakub Kadlcik <frostyx@email.cz>
Date: Wed, 13 Jan 2021 15:06:16 +0100
Subject: [PATCH 2/2] modulemd_tools: temporarily skip some tests on EPEL8
---
modulemd_tools/tests/test_yaml.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/modulemd_tools/tests/test_yaml.py b/modulemd_tools/tests/test_yaml.py
index ed5520cc86ded2e67994aa79ef8eeace9e7432ae..b079f65304cadb229fc475d8314f2c6233a7137a 100644
--- a/modulemd_tools/tests/test_yaml.py
+++ b/modulemd_tools/tests/test_yaml.py
@@ -1,13 +1,29 @@
import os
import unittest
from unittest import mock
from parameterized import parameterized
import yaml
+from distutils.version import LooseVersion
from modulemd_tools.yaml import (is_valid, validate, create, update, dump,
upgrade, _yaml2stream, _stream2yaml)
+import gi
+gi.require_version("Modulemd", "2.0")
+from gi.repository import Modulemd
+
+
+def old_libmodulemd():
+ """
+ Reading YAML string via `Modulemd.ModuleStream.read_string` and dumping it
+ again encapsulates its value in double-quotes, and it messes up with some of
+ our tests (since the older version does exactly the opposite). Let's just
+ skip those few test on EPEL8 until it receives an update.
+ See also `080e2bb`
+ """
+ return LooseVersion(Modulemd.get_version()) < LooseVersion("2.11.1")
+
class TestYaml(unittest.TestCase):
def test_is_valid(self):
self.assertTrue(is_valid(yaml1))
@@ -298,10 +314,11 @@ class TestYaml(unittest.TestCase):
self.assertEqual(mod_stream.get_mdversion(), 2)
self.assertEqual(mod_stream.get_module_name(), "")
self.assertEqual(mod_stream.get_summary(),
"A test module in all its beautiful beauty")
+ @unittest.skipIf(old_libmodulemd(), "Old modulemd drops stream value quotes")
def test_upgrade_to_same_version(self):
result = upgrade(yaml1, 2)
self.assertEqual(result, yaml1)
def test_upgrade_cannot_downgrade(self):
@@ -364,10 +381,11 @@ class TestYaml(unittest.TestCase):
with self.assertRaises(ValueError) as context:
_yaml2stream(yaml5_multiple_modules)
self.assertIn("YAML contained more than a single subdocument",
str(context.exception))
+ @unittest.skipIf(old_libmodulemd(), "Old modulemd drops stream value quotes")
def test_stream2yaml(self):
mod_stream = _yaml2stream(yaml1)
self.assertEqual(_stream2yaml(mod_stream), yaml1)
mod_stream.set_summary(None)
--
2.29.2

View File

@ -1,6 +1,6 @@
Name: modulemd-tools
Version: 0.6
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Collection of tools for parsing and generating modulemd YAML files
License: MIT
BuildArch: noarch
@ -8,12 +8,12 @@ BuildArch: noarch
URL: https://github.com/rpm-software-management/modulemd-tools
Source0: https://github.com/rpm-software-management/modulemd-tools/archive/%{version}/%{name}-%{version}.tar.gz
BuildRequires: libmodulemd >= 2
BuildRequires: createrepo_c
BuildRequires: argparse-manpage
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-gobject
BuildRequires: python3-gobject-base
BuildRequires: python3-libmodulemd >= 2.9.3
BuildRequires: python3-click
%if ! 0%{?rhel}
BuildRequires: python3-click-man
@ -31,6 +31,13 @@ Requires: python3-dnf
Requires: python3-hawkey
Requires: python3-createrepo_c
Requires: python3-pyyaml
Requires: python3-gobject-base
Requires: python3-libmodulemd >= 2.9.3
# Upstream patches to fix compilation against libmodulemd 2.12
Patch0001: 0001-modulemd_tools-quote-stream-fields-in-test-suite.patch
Patch0002: 0002-modulemd_tools-temporarily-skip-some-tests-on-EPEL8.patch
%description
@ -56,7 +63,7 @@ modulemd-generate-macros - Generate module-build-macros SRPM package, which is
%prep
%setup -q
%autosetup -p1
%build
@ -114,6 +121,9 @@ cd modulemd_tools
%changelog
* Fri Jan 22 2021 Stephen Gallagher <sgallagh@redhat.com> 0.6-2
- Fix build against libmodulemd-2.12
* Sun Nov 22 2020 Jakub Kadlcik <frostyx@email.cz> 0.6-1
- Generate manpages for all tools in this repository
- modulemd-generate-macros: add a tool for generating module-build-macros