From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/emerge/
Date: Mon, 30 Oct 2023 03:14:28 +0000 (UTC) [thread overview]
Message-ID: <1698635662.2dde25d65a1131f8298265ead1028716a814f27d.sam@gentoo> (raw)
commit: 2dde25d65a1131f8298265ead1028716a814f27d
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri Jul 7 13:29:23 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 03:14:22 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2dde25d6
tests/emerge: test_simple.py: Complete pytest parametrization
Complete pytest parametrization. The test_simple_emerge is completely
parametrized in commands and in binary formats. This commit is the first
implementation. Further refactorings/improvements shall follow.
Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/tests/emerge/conftest.py | 590 ++++++++++++++++++++++----------
lib/portage/tests/emerge/test_simple.py | 19 +-
2 files changed, 419 insertions(+), 190 deletions(-)
diff --git a/lib/portage/tests/emerge/conftest.py b/lib/portage/tests/emerge/conftest.py
index 6f78f17935..a637aa885b 100644
--- a/lib/portage/tests/emerge/conftest.py
+++ b/lib/portage/tests/emerge/conftest.py
@@ -12,9 +12,11 @@ from portage.tests.resolver.ResolverPlayground import ResolverPlayground
from portage.cache.mappings import Mapping
from portage.tests.util.test_socks5 import AsyncHTTPServer
from portage import os
+from portage import shutil
from portage.util.futures import asyncio
from portage.tests import cnf_bindir, cnf_sbindir
from portage.process import find_binary
+from portage.util import find_updated_config_files, shlex_split
import portage
import pytest
@@ -176,6 +178,36 @@ _INSTALLED_EBUILDS = {
}
+# class SimpleTestCommand:
+# """A class that represents a simple test case command,
+# including post checks, preparation and cleanup.
+# """
+# def __init__(self, command, *options, environment=None):
+# self._command = command
+# self._options = options
+# if environment is None:
+# environment = {}
+# self.environment = environment
+
+# def prepare(self):
+# ...
+
+# def cleanup(self):
+# ...
+
+
+_TEST_COMMAND_NAMES_FETCHCOMMAND = [
+ "mv {pkgdir} {binhost_dir}",
+ "emerge -eG dev-libs/A",
+ "rm -R {pkgdir} (1)",
+ "mv {binhost_dir} {pkgdir}",
+ "rm {binrepos_conf_file}",
+ "mv {pkgdir} {binhost_dir} (2)",
+ "PORTAGE_BINHOST={binhost_uri} emerge -feG dev-libs/A",
+ "rm -R {pkgdir} (2)",
+ "mv {binhost_dir} {pkgdir} (2)",
+]
+
_TEST_COMMAND_NAMES = [
"emerge_w_parse_intermixed_args",
"emerge --root --quickpkg-direct-root",
@@ -204,7 +236,66 @@ _TEST_COMMAND_NAMES = [
"emerge --metadata",
"rm -rf {cachedir} (6)",
"emerge --oneshot virtual/foo",
-]
+ "foo pkg missing",
+ "FEATURES=unmerge-backup emerge --unmerge virtual/foo",
+ "foo pkg exists",
+ "emerge --pretend dev-libs/A",
+ "ebuild dev-libs/A-1 manifest clean package merge",
+ "emerge --pretend --tree --complete-graph dev-libs/A",
+ "emerge -p dev-libs/B",
+ "emerge -p --newrepo dev-libs/B",
+ "emerge -B dev-libs/B",
+ "emerge -1k dev-libs/B",
+ "ebuild dev-libs/A-1 unpack",
+ "emerge -1 dev-libs/A",
+ "emerge -n dev-libs/A",
+ "emerge --config dev-libs/A",
+ "emerge --info dev-libs/A dev-libs/B",
+ "emerge -pcv dev-libs/B",
+ "emerge -pc",
+ "emerge -c",
+ "quickpkg --include-config y dev-libs/A",
+ "no protected files",
+ "rm /etc/A-0",
+ "emerge -K dev-libs/A",
+ "one protected file",
+ "emaint --check all",
+ "emaint --fix all",
+ "fixpackages",
+ "regenworld",
+ "portageq match {eroot} dev-libs/A",
+ "portageq best_visible {eroot} dev-libs/A",
+ "portageq best_visible {eroot} binary dev-libs/A",
+ "portageq contents {eroot} dev-libs/A-1",
+ "portageq metadata {eroot} ebuild dev-libs/A-1 EAPI IUSE RDEPEND",
+ "portageq metadata {eroot} binary dev-libs/A-1 EAPI USE RDEPEND",
+ "portageq metadata {eroot} installed dev-libs/A-1 EAPI USE RDEPEND",
+ "portageq owners {eroot} {eroot}usr",
+ "emerge -p {eroot}usr",
+ "emerge -pCq {eroot}usr",
+ "emerge -Cq dev-libs/A",
+ "emerge -Cq dev-libs/B",
+ (
+ "EMERGE_DEFAULT_OPTS=--autounmask=n "
+ "emerge --autounmask --autounmask-continue dev-libs/C"
+ ),
+ "portageq match {eroot} dev-libs/D[flag]",
+ "EPREFIX={cross_prefix} emerge dev-libs/C",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/C",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/D",
+ "ROOT={cross_root} emerge dev-libs/D",
+ "portageq has_version {cross_eroot} dev-libs/D",
+ "EPREFIX={cross_prefix} emerge -K dev-libs/A",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/A",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B",
+ "EPREFIX={cross_prefix} emerge -Cq dev-libs/B",
+ "EPREFIX={cross_prefix} emerge -Cq dev-libs/A",
+ "EPREFIX={cross_prefix} emerge dev-libs/A",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/A (2)",
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B (2)",
+ "ROOT={cross_root} emerge dev-libs/B",
+ "portageq has_version {cross_eroot} dev-libs/B",
+] + _TEST_COMMAND_NAMES_FETCHCOMMAND
def pytest_generate_tests(metafunc):
@@ -221,6 +312,18 @@ def _have_python_xml():
return True
+def _check_foo_file(pkgdir, filename, must_exist) -> None:
+ assert (
+ os.path.exists(os.path.join(pkgdir, "virtual", "foo", filename)) == must_exist
+ )
+
+
+def _check_number_of_protected_files(must_have, eroot, config_protect) -> None:
+ assert must_have == len(
+ list(find_updated_config_files(eroot, shlex_split(config_protect)))
+ )
+
+
class BinhostContentMap(Mapping):
def __init__(self, remote_path, local_path):
self._remote_path = remote_path
@@ -240,13 +343,13 @@ class BinhostContentMap(Mapping):
raise KeyError(request_path)
-@pytest.fixture()
+@pytest.fixture(scope="module")
def async_loop():
yield asyncio._wrap_loop()
-@pytest.fixture(params=SUPPORTED_GENTOO_BINPKG_FORMATS)
-def playground(request):
+@pytest.fixture(params=SUPPORTED_GENTOO_BINPKG_FORMATS, scope="module")
+def playground(request, tmp_path_factory):
"""Fixture that provides instances of ``ResolverPlayground``
each one with one supported value for ``BINPKG_FORMAT``."""
binpkg_format = request.param
@@ -257,6 +360,7 @@ def playground(request):
user_config={
"make.conf": (f'BINPKG_FORMAT="{binpkg_format}"',),
},
+ eprefix=str(tmp_path_factory.mktemp("eprefix", numbered=True)),
)
yield playground
playground.cleanup()
@@ -287,6 +391,7 @@ def simple_command(playground, binhost, request):
eprefix = settings["EPREFIX"]
eroot = settings["EROOT"]
trees = playground.trees
+ pkgdir = playground.pkgdir
portdb = trees[eroot]["porttree"].dbapi
test_repo_location = settings.repositories["test_repo"].location
var_cache_edb = os.path.join(eprefix, "var", "cache", "edb")
@@ -434,185 +539,308 @@ def simple_command(playground, binhost, request):
)
test_commands["emerge --metadata"] = emerge_cmd + ("--metadata",)
test_commands["rm -rf {cachedir} (6)"] = rm_cmd + ("-rf", cachedir)
+
test_commands["emerge --oneshot virtual/foo"] = emerge_cmd + (
"--oneshot",
"virtual/foo",
)
- # test_commands["virtual/foo exists"] = (
- # lambda: self.assertFalse(
- # os.path.exists(os.path.join(pkgdir, "virtual", "foo", foo_filename))
- # )
- # )
- # ({"FEATURES": "unmerge-backup"},) + emerge_cmd + ("--unmerge", "virtual/foo"),
- # lambda: self.assertTrue(
- # os.path.exists(os.path.join(pkgdir, "virtual", "foo", foo_filename))
- # ),
- # emerge_cmd + ("--pretend", "dev-libs/A"),
- # ebuild_cmd + (test_ebuild, "manifest", "clean", "package", "merge"),
- # emerge_cmd + ("--pretend", "--tree", "--complete-graph", "dev-libs/A"),
- # emerge_cmd + ("-p", "dev-libs/B"),
- # emerge_cmd + ("-p", "--newrepo", "dev-libs/B"),
- # emerge_cmd
- # + (
- # "-B",
- # "dev-libs/B",
- # ),
- # emerge_cmd
- # + (
- # "--oneshot",
- # "--usepkg",
- # "dev-libs/B",
- # ),
- # # trigger clean prior to pkg_pretend as in bug #390711
- # ebuild_cmd + (test_ebuild, "unpack"),
- # emerge_cmd
- # + (
- # "--oneshot",
- # "dev-libs/A",
- # ),
- # emerge_cmd
- # + (
- # "--noreplace",
- # "dev-libs/A",
- # ),
- # emerge_cmd
- # + (
- # "--config",
- # "dev-libs/A",
- # ),
- # emerge_cmd + ("--info", "dev-libs/A", "dev-libs/B"),
- # emerge_cmd + ("--pretend", "--depclean", "--verbose", "dev-libs/B"),
- # emerge_cmd
- # + (
- # "--pretend",
- # "--depclean",
- # ),
- # emerge_cmd + ("--depclean",),
- # quickpkg_cmd
- # + (
- # "--include-config",
- # "y",
- # "dev-libs/A",
- # ),
- # # Test bug #523684, where a file renamed or removed by the
- # # admin forces replacement files to be merged with config
- # # protection.
- # lambda: self.assertEqual(
- # 0,
- # len(
- # list(
- # find_updated_config_files(
- # eroot, shlex_split(settings["CONFIG_PROTECT"])
- # )
- # )
- # ),
- # ),
- # lambda: os.unlink(os.path.join(eprefix, "etc", "A-0")),
- # emerge_cmd + ("--usepkgonly", "dev-libs/A"),
- # lambda: self.assertEqual(
- # 1,
- # len(
- # list(
- # find_updated_config_files(
- # eroot, shlex_split(settings["CONFIG_PROTECT"])
- # )
- # )
- # ),
- # ),
- # emaint_cmd + ("--check", "all"),
- # emaint_cmd + ("--fix", "all"),
- # fixpackages_cmd,
- # regenworld_cmd,
- # portageq_cmd + ("match", eroot, "dev-libs/A"),
- # portageq_cmd + ("best_visible", eroot, "dev-libs/A"),
- # portageq_cmd + ("best_visible", eroot, "binary", "dev-libs/A"),
- # portageq_cmd + ("contents", eroot, "dev-libs/A-1"),
- # portageq_cmd
- # + ("metadata", eroot, "ebuild", "dev-libs/A-1", "EAPI", "IUSE", "RDEPEND"),
- # portageq_cmd
- # + ("metadata", eroot, "binary", "dev-libs/A-1", "EAPI", "USE", "RDEPEND"),
- # portageq_cmd
- # + (
- # "metadata",
- # eroot,
- # "installed",
- # "dev-libs/A-1",
- # "EAPI",
- # "USE",
- # "RDEPEND",
- # ),
- # portageq_cmd + ("owners", eroot, eroot + "usr"),
- # emerge_cmd + ("-p", eroot + "usr"),
- # emerge_cmd + ("-p", "--unmerge", "-q", eroot + "usr"),
- # emerge_cmd + ("--unmerge", "--quiet", "dev-libs/A"),
- # emerge_cmd + ("-C", "--quiet", "dev-libs/B"),
- # # If EMERGE_DEFAULT_OPTS contains --autounmask=n, then --autounmask
- # # must be specified with --autounmask-continue.
- # ({"EMERGE_DEFAULT_OPTS": "--autounmask=n"},)
- # + emerge_cmd
- # + (
- # "--autounmask",
- # "--autounmask-continue",
- # "dev-libs/C",
- # ),
- # # Verify that the above --autounmask-continue command caused
- # # USE=flag to be applied correctly to dev-libs/D.
- # portageq_cmd + ("match", eroot, "dev-libs/D[flag]"),
- # # Test cross-prefix usage, including chpathtool for binpkgs.
- # # EAPI 7
- # ({"EPREFIX": cross_prefix},) + emerge_cmd + ("dev-libs/C",),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/C"),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/D"),
- # ({"ROOT": cross_root},) + emerge_cmd + ("dev-libs/D",),
- # portageq_cmd + ("has_version", cross_eroot, "dev-libs/D"),
- # # EAPI 5
- # ({"EPREFIX": cross_prefix},) + emerge_cmd + ("--usepkgonly", "dev-libs/A"),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/A"),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/B"),
- # ({"EPREFIX": cross_prefix},) + emerge_cmd + ("-C", "--quiet", "dev-libs/B"),
- # ({"EPREFIX": cross_prefix},) + emerge_cmd + ("-C", "--quiet", "dev-libs/A"),
- # ({"EPREFIX": cross_prefix},) + emerge_cmd + ("dev-libs/A",),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/A"),
- # ({"EPREFIX": cross_prefix},)
- # + portageq_cmd
- # + ("has_version", cross_prefix, "dev-libs/B"),
- # # Test ROOT support
- # ({"ROOT": cross_root},) + emerge_cmd + ("dev-libs/B",),
- # portageq_cmd + ("has_version", cross_eroot, "dev-libs/B"),
- # )
-
- # # Test binhost support if FETCHCOMMAND is available.
- # binrepos_conf_file = os.path.join(os.sep, eprefix, BINREPOS_CONF_FILE)
- # binhost_uri = binhost["uri"]
- # binhost_dir = binhost["dir"]
- # with open(binrepos_conf_file, "w") as f:
- # f.write("[test-binhost]\n")
- # f.write(f"sync-uri = {binhost_uri}\n")
- # fetchcommand = portage.util.shlex_split(settings["FETCHCOMMAND"])
- # fetch_bin = portage.process.find_binary(fetchcommand[0])
- # if fetch_bin is not None:
- # test_commands = test_commands + (
- # lambda: os.rename(pkgdir, binhost_dir),
- # emerge_cmd + ("-e", "--getbinpkgonly", "dev-libs/A"),
- # lambda: shutil.rmtree(pkgdir),
- # lambda: os.rename(binhost_dir, pkgdir),
- # # Remove binrepos.conf and test PORTAGE_BINHOST.
- # lambda: os.unlink(binrepos_conf_file),
- # lambda: os.rename(pkgdir, binhost_dir),
- # ({"PORTAGE_BINHOST": binhost_uri},)
- # + emerge_cmd
- # + ("-fe", "--getbinpkgonly", "dev-libs/A"),
- # lambda: shutil.rmtree(pkgdir),
- # lambda: os.rename(binhost_dir, pkgdir),
- # )
+ test_commands["foo pkg missing"] = lambda: _check_foo_file(
+ pkgdir, foo_filename, must_exist=False
+ )
+
+ test_commands["FEATURES=unmerge-backup emerge --unmerge virtual/foo"] = (
+ ({"FEATURES": "unmerge-backup"},) + emerge_cmd + ("--unmerge", "virtual/foo")
+ )
+ test_commands["foo pkg exists"] = lambda: _check_foo_file(
+ pkgdir, foo_filename, must_exist=True
+ )
+
+ test_commands["emerge --pretend dev-libs/A"] = emerge_cmd + (
+ "--pretend",
+ "dev-libs/A",
+ )
+
+ test_commands["ebuild dev-libs/A-1 manifest clean package merge"] = ebuild_cmd + (
+ test_ebuild,
+ "manifest",
+ "clean",
+ "package",
+ "merge",
+ )
+ test_commands[
+ "emerge --pretend --tree --complete-graph dev-libs/A"
+ ] = emerge_cmd + ("--pretend", "--tree", "--complete-graph", "dev-libs/A")
+ test_commands["emerge -p dev-libs/B"] = emerge_cmd + ("-p", "dev-libs/B")
+ test_commands["emerge -p --newrepo dev-libs/B"] = emerge_cmd + (
+ "-p",
+ "--newrepo",
+ "dev-libs/B",
+ )
+ test_commands["emerge -B dev-libs/B"] = emerge_cmd + (
+ "-B",
+ "dev-libs/B",
+ )
+ test_commands["emerge -1k dev-libs/B"] = emerge_cmd + (
+ "--oneshot",
+ "--usepkg",
+ "dev-libs/B",
+ )
+ # trigger clean prior to pkg_pretend as in bug #390711
+ test_commands["ebuild dev-libs/A-1 unpack"] = ebuild_cmd + (test_ebuild, "unpack")
+ test_commands["emerge -1 dev-libs/A"] = emerge_cmd + ("--oneshot", "dev-libs/A")
+ test_commands["emerge -n dev-libs/A"] = emerge_cmd + ("--noreplace", "dev-libs/A")
+ test_commands["emerge --config dev-libs/A"] = emerge_cmd + (
+ "--config",
+ "dev-libs/A",
+ )
+ test_commands["emerge --info dev-libs/A dev-libs/B"] = emerge_cmd + (
+ "--info",
+ "dev-libs/A",
+ "dev-libs/B",
+ )
+ test_commands["emerge -pcv dev-libs/B"] = emerge_cmd + (
+ "--pretend",
+ "--depclean",
+ "--verbose",
+ "dev-libs/B",
+ )
+ test_commands["emerge -pc"] = emerge_cmd + ("--pretend", "--depclean")
+ test_commands["emerge -c"] = emerge_cmd + ("--depclean",)
+ test_commands["quickpkg --include-config y dev-libs/A"] = quickpkg_cmd + (
+ "--include-config",
+ "y",
+ "dev-libs/A",
+ )
+ # Test bug #523684, where a file renamed or removed by the
+ # admin forces replacement files to be merged with config
+ # protection.
+ test_commands["no protected files"] = lambda: _check_number_of_protected_files(
+ 0, eroot, settings["CONFIG_PROTECT"]
+ )
+ # Another "it is not a test command" case; actually setup:
+ test_commands["rm /etc/A-0"] = lambda: os.unlink(
+ os.path.join(eprefix, "etc", "A-0")
+ )
+ test_commands["emerge -K dev-libs/A"] = emerge_cmd + ("--usepkgonly", "dev-libs/A")
+ test_commands["one protected file"] = lambda: _check_number_of_protected_files(
+ 1, eroot, settings["CONFIG_PROTECT"]
+ )
+
+ test_commands["emaint --check all"] = emaint_cmd + ("--check", "all")
+ test_commands["emaint --fix all"] = emaint_cmd + ("--fix", "all")
+ test_commands["fixpackages"] = fixpackages_cmd
+ test_commands["regenworld"] = regenworld_cmd
+ test_commands["portageq match {eroot} dev-libs/A"] = portageq_cmd + (
+ "match",
+ eroot,
+ "dev-libs/A",
+ )
+ test_commands["portageq best_visible {eroot} dev-libs/A"] = portageq_cmd + (
+ "best_visible",
+ eroot,
+ "dev-libs/A",
+ )
+ test_commands["portageq best_visible {eroot} binary dev-libs/A"] = portageq_cmd + (
+ "best_visible",
+ eroot,
+ "binary",
+ "dev-libs/A",
+ )
+ test_commands["portageq contents {eroot} dev-libs/A-1"] = portageq_cmd + (
+ "contents",
+ eroot,
+ "dev-libs/A-1",
+ )
+ test_commands[
+ "portageq metadata {eroot} ebuild dev-libs/A-1 EAPI IUSE RDEPEND"
+ ] = portageq_cmd + (
+ "metadata",
+ eroot,
+ "ebuild",
+ "dev-libs/A-1",
+ "EAPI",
+ "IUSE",
+ "RDEPEND",
+ )
+ test_commands[
+ "portageq metadata {eroot} binary dev-libs/A-1 EAPI USE RDEPEND"
+ ] = portageq_cmd + (
+ "metadata",
+ eroot,
+ "binary",
+ "dev-libs/A-1",
+ "EAPI",
+ "USE",
+ "RDEPEND",
+ )
+ test_commands[
+ "portageq metadata {eroot} installed dev-libs/A-1 EAPI USE RDEPEND"
+ ] = portageq_cmd + (
+ "metadata",
+ eroot,
+ "installed",
+ "dev-libs/A-1",
+ "EAPI",
+ "USE",
+ "RDEPEND",
+ )
+ test_commands["portageq owners {eroot} {eroot}usr"] = portageq_cmd + (
+ "owners",
+ eroot,
+ eroot + "usr",
+ )
+ test_commands["emerge -p {eroot}usr"] = emerge_cmd + ("-p", eroot + "usr")
+ test_commands["emerge -pCq {eroot}usr"] = emerge_cmd + (
+ "-p",
+ "--unmerge",
+ "-q",
+ eroot + "usr",
+ )
+ test_commands["emerge -Cq dev-libs/A"] = emerge_cmd + (
+ "--unmerge",
+ "--quiet",
+ "dev-libs/A",
+ )
+ test_commands["emerge -Cq dev-libs/B"] = emerge_cmd + (
+ "-C",
+ "--quiet",
+ "dev-libs/B",
+ )
+
+ # autounmask:
+ # If EMERGE_DEFAULT_OPTS contains --autounmask=n, then --autounmask
+ # must be specified with --autounmask-continue.
+ test_commands[
+ "EMERGE_DEFAULT_OPTS=--autounmask=n "
+ "emerge --autounmask --autounmask-continue dev-libs/C"
+ ] = (
+ ({"EMERGE_DEFAULT_OPTS": "--autounmask=n"},)
+ + emerge_cmd
+ + ("--autounmask", "--autounmask-continue", "dev-libs/C")
+ )
+ # Verify that the above --autounmask-continue command caused
+ # USE=flag to be applied correctly to dev-libs/D.
+ test_commands["portageq match {eroot} dev-libs/D[flag]"] = portageq_cmd + (
+ "match",
+ eroot,
+ "dev-libs/D[flag]",
+ )
+ # Test cross-prefix usage, including chpathtool for binpkgs.
+ # EAPI 7
+ test_commands["EPREFIX={cross_prefix} emerge dev-libs/C"] = (
+ ({"EPREFIX": cross_prefix},) + emerge_cmd + ("dev-libs/C",)
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/C"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/C")
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/D"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/D")
+ )
+ test_commands["ROOT={cross_root} emerge dev-libs/D"] = (
+ ({"ROOT": cross_root},) + emerge_cmd + ("dev-libs/D",)
+ )
+ test_commands["portageq has_version {cross_eroot} dev-libs/D"] = portageq_cmd + (
+ "has_version",
+ cross_eroot,
+ "dev-libs/D",
+ )
+ # EAPI 5
+ test_commands["EPREFIX={cross_prefix} emerge -K dev-libs/A"] = (
+ ({"EPREFIX": cross_prefix},) + emerge_cmd + ("--usepkgonly", "dev-libs/A")
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/A"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/A")
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/B")
+ )
+ test_commands["EPREFIX={cross_prefix} emerge -Cq dev-libs/B"] = (
+ ({"EPREFIX": cross_prefix},) + emerge_cmd + ("-C", "--quiet", "dev-libs/B")
+ )
+ test_commands["EPREFIX={cross_prefix} emerge -Cq dev-libs/A"] = (
+ ({"EPREFIX": cross_prefix},) + emerge_cmd + ("-C", "--quiet", "dev-libs/A")
+ )
+ test_commands["EPREFIX={cross_prefix} emerge dev-libs/A"] = (
+ ({"EPREFIX": cross_prefix},) + emerge_cmd + ("dev-libs/A",)
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/A (2)"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/A")
+ )
+ test_commands[
+ "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B (2)"
+ ] = (
+ ({"EPREFIX": cross_prefix},)
+ + portageq_cmd
+ + ("has_version", cross_prefix, "dev-libs/B")
+ )
+ # Test ROOT support
+ test_commands["ROOT={cross_root} emerge dev-libs/B"] = (
+ ({"ROOT": cross_root},) + emerge_cmd + ("dev-libs/B",)
+ )
+ test_commands["portageq has_version {cross_eroot} dev-libs/B"] = portageq_cmd + (
+ "has_version",
+ cross_eroot,
+ "dev-libs/B",
+ )
+
+ # Test binhost support if FETCHCOMMAND is available.
+ binrepos_conf_file = os.path.join(os.sep, eprefix, BINREPOS_CONF_FILE)
+ binhost_uri = binhost["uri"]
+ binhost_dir = binhost["dir"]
+ with open(binrepos_conf_file, "w") as f:
+ f.write("[test-binhost]\n")
+ f.write(f"sync-uri = {binhost_uri}\n")
+ fetchcommand = portage.util.shlex_split(settings["FETCHCOMMAND"])
+ fetch_bin = portage.process.find_binary(fetchcommand[0])
+ if fetch_bin is None:
+ for command_name in _TEST_COMMAND_NAMES_FETCHCOMMAND:
+ test_commands[command_name] = lambda: ...
+ else:
+ test_commands["mv {pkgdir} {binhost_dir}"] = lambda: os.rename(
+ pkgdir, binhost_dir
+ )
+ test_commands["emerge -eG dev-libs/A"] = emerge_cmd + (
+ "-e",
+ "--getbinpkgonly",
+ "dev-libs/A",
+ )
+ test_commands["rm -R {pkgdir} (1)"] = lambda: shutil.rmtree(pkgdir)
+ test_commands["mv {binhost_dir} {pkgdir}"] = lambda: os.rename(
+ binhost_dir, pkgdir
+ )
+ # Remove binrepos.conf and test PORTAGE_BINHOST.
+ test_commands["rm {binrepos_conf_file}"] = lambda: os.unlink(binrepos_conf_file)
+ test_commands["mv {pkgdir} {binhost_dir} (2)"] = lambda: os.rename(
+ pkgdir, binhost_dir
+ )
+ test_commands["PORTAGE_BINHOST={binhost_uri} emerge -feG dev-libs/A"] = (
+ ({"PORTAGE_BINHOST": binhost_uri},)
+ + emerge_cmd
+ + ("-fe", "--getbinpkgonly", "dev-libs/A")
+ )
+ test_commands["rm -R {pkgdir} (2)"] = lambda: shutil.rmtree(pkgdir)
+ test_commands["mv {binhost_dir} {pkgdir} (2)"] = lambda: os.rename(
+ binhost_dir, pkgdir
+ )
+
return test_commands[request.param]
diff --git a/lib/portage/tests/emerge/test_simple.py b/lib/portage/tests/emerge/test_simple.py
index 6e417f8de3..700ddd9764 100644
--- a/lib/portage/tests/emerge/test_simple.py
+++ b/lib/portage/tests/emerge/test_simple.py
@@ -4,15 +4,14 @@
import subprocess
import portage
-from portage import shutil, os
+from portage import os
from portage.const import (
PORTAGE_PYM_PATH,
USER_CONFIG_PATH,
- SUPPORTED_GENTOO_BINPKG_FORMATS,
)
from portage.process import find_binary
from portage.tests import cnf_etc_path
-from portage.util import ensure_dirs, find_updated_config_files, shlex_split
+from portage.util import ensure_dirs
from portage.util.futures import asyncio
@@ -32,10 +31,6 @@ _METADATA_XML_FILES = (
)
-class SimpleTestCommand:
- ...
-
-
def test_simple_emerge(async_loop, playground, binhost, simple_command):
async_loop.run_until_complete(
asyncio.ensure_future(
@@ -145,9 +140,15 @@ async def _async_test_simple(playground, binhost, command, metadata_xml_files, l
for d in dirs:
ensure_dirs(d)
for x in true_symlinks:
- os.symlink(true_binary, os.path.join(fake_bin, x))
+ try:
+ os.symlink(true_binary, os.path.join(fake_bin, x))
+ except FileExistsError:
+ pass
for x in etc_symlinks:
- os.symlink(os.path.join(cnf_etc_path, x), os.path.join(eprefix, "etc", x))
+ try:
+ os.symlink(os.path.join(cnf_etc_path, x), os.path.join(eprefix, "etc", x))
+ except FileExistsError:
+ pass
with open(os.path.join(var_cache_edb, "counter"), "wb") as f:
f.write(b"100")
# non-empty system set keeps --depclean quiet
next reply other threads:[~2023-10-30 3:14 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 3:14 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-25 8:25 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/emerge/ Sam James
2024-02-24 3:36 Zac Medico
2024-01-03 19:59 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-10-30 3:14 Sam James
2023-05-26 15:45 Sam James
2023-05-26 15:45 Sam James
2022-09-25 19:12 Mike Gilbert
2021-01-18 12:20 Zac Medico
2020-10-17 9:21 Zac Medico
2020-10-12 18:03 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 19:30 Zac Medico
2020-03-08 22:29 Zac Medico
2020-03-08 7:33 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1698635662.2dde25d65a1131f8298265ead1028716a814f27d.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox