#1540 backend: fix testsuite for the new createrepo_c
Merged 3 years ago by msuchy. Opened 3 years ago by praiskup.
Unknown source fix-1536  into  master

@@ -1,13 +1,14 @@

  import contextlib

  import os

- import importlib

  import logging

- from unittest import mock

- import pytest

  import runpy

  import shutil

  import subprocess

  import tempfile

+ from unittest import mock

+ 

+ import pytest

+ from packaging import version

  import munch

  

  from copr_backend.helpers import (
@@ -309,13 +310,17 @@

          assert call_copr_repo(chrootdir, add=[ctx.builds[1]])

  

          repoinfo = load_primary_xml(repodata)

-         # TODO: the output should be empty

-         # https://github.com/rpm-software-management/createrepo_c/issues/222

-         # assert repoinfo['hrefs'] == set()

-         assert repoinfo['hrefs'] == set([

-             '00000001-prunerepo/prunerepo-1.1-1.fc23.noarch.rpm',

-             '00000003-example/example-1.0.14-1.fc30.x86_64.rpm',

-         ])

+         output = subprocess.check_output(["createrepo_c", "--version"],

+                                          universal_newlines=True)

+         expected_hrefs = set()

+         if version.parse(output.split()[1]) < version.parse("0.16.1"):

+             # https://github.com/rpm-software-management/createrepo_c/issues/222

+             expected_hrefs = set([

+                 '00000001-prunerepo/prunerepo-1.1-1.fc23.noarch.rpm',

+                 '00000003-example/example-1.0.14-1.fc30.x86_64.rpm',

+             ])

+         assert repoinfo['hrefs'] == expected_hrefs

+ 

  

      @mock.patch.dict(os.environ, {'COPR_TESTSUITE_NO_OUTPUT': '1'})

      def test_copr_repo_add_subdir_devel(self, f_acr_on_and_first_build):

There's one expected non-fatal failure with createrepo_c <= v0.15.1,
because upstream of createrepo_c fixed the bug we reported.

Fixes: #1536

Would it be possible to write this way, or it won't work?

# createrepo_c < v16.1
# https://github.com/rpm-software-management/createrepo_c/issues/222
if repoinfo['hrefs'] == set([
    '00000001-prunerepo/prunerepo-1.1-1.fc23.noarch.rpm',
    '00000003-example/example-1.0.14-1.fc30.x86_64.rpm',
]):
    pytest.xfail("old createrepo_c")

assert repoinfo['hrefs'] == set()

By not having an assert in the proposed version, I am afraid that after some time we might forget what we are even testing.

rebased onto 251ea79

3 years ago

Ok, please check the updated version. On top of what you wrote, I was afraid that the new versions of craterepo could regress back ... so I added a check for the createrepo version.

Pull-Request has been merged by msuchy

3 years ago