pungi/tests/test_fus_wrapper.py
Lubomír Sedlář ba0193ca28 gather: Add a hybrid depsolver backend
This patch adds a new gather method called `hybrid`, which uses a `fus`
binary, which must exist somewhere on the `$PATH`. It will call it
multiple times to add multilib packages.

The solver can handle packages, modules and comps groups as input.
However comps groups are never passed in. Pungi will expand it to a list
of packages to avoid issues with comps handling in fus. It ignores
optional packages, and if the group mentions a package that does not
exist, nothing else from the group is included.

Multilib is also handled outside of fus. Pungi will run it, parse the
packages from output, determines multilib packages and adds them as
input. Then it runs the solver again. This is done until nothing new is
added. Usually two passes should be enough.

Source packages and debuginfo are added as a final step. All debuginfo
packages from any included source are added. If the source or debuginfo
package is included in any lookaside repo, it will be skipped.

The tool expects to get a platform stream that should be provided for
modules to depend on. Pungi looks into the modules and gets the platform
from there. If there are more requests, an error is raised.

There is some missing functionality and options that are ignored.
Particularly these are:

 * gather_fulltree
 * gather_selfhosting
 * greedy_method

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
2018-07-16 10:21:41 +02:00

78 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
try:
import unittest2 as unittest
except ImportError:
import unittest
import tempfile
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi.wrappers import fus
from .helpers import touch
class TestGetCmd(unittest.TestCase):
def test_minimum_command(self):
cmd = fus.get_cmd("x86_64", [], [], [], [], [])
self.assertEqual(cmd, ["fus", "--verbose", "--arch", "x86_64"])
def test_full_command(self):
cmd = fus.get_cmd(
"x86_64",
["/tmp/first", "/tmp/second"],
["/tmp/fst", "/tmp/snd"],
["pkg"],
["mod:1.0"],
platform="f29",
)
self.assertEqual(
cmd,
[
"fus",
"--verbose",
"--arch",
"x86_64",
"--repo=repo-0,repo,/tmp/first",
"--repo=repo-1,repo,/tmp/second",
"--repo=lookaside-0,lookaside,/tmp/fst",
"--repo=lookaside-1,lookaside,/tmp/snd",
"--platform=f29",
"module(mod:1.0)",
"pkg",
],
)
class TestParseOutput(unittest.TestCase):
def setUp(self):
_, self.file = tempfile.mkstemp(prefix="test-parse-fus-out-")
def tearDown(self):
os.remove(self.file)
def test_skips_debug_line(self):
touch(self.file, "debug line\n")
packages, modules = fus.parse_output(self.file)
self.assertItemsEqual(packages, [])
self.assertItemsEqual(modules, [])
def test_separates_arch(self):
touch(self.file, "pkg-1.0-1.x86_64@repo-0\npkg-1.0-1.i686@repo-0\n")
packages, modules = fus.parse_output(self.file)
self.assertItemsEqual(
packages,
[("pkg-1.0-1", "x86_64"), ("pkg-1.0-1", "i686")],
)
self.assertItemsEqual(modules, [])
def test_returns_modules(self):
touch(self.file, "module:foo:1:201807131350:deadcafe.x86_64@repo-0\n")
packages, modules = fus.parse_output(self.file)
self.assertItemsEqual(packages, [])
self.assertItemsEqual(modules, ["foo:1:201807131350:deadcafe"])