commit: b6a5a31808f2f5548e3699184bd20d110ae77ee1
Author: David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri Sep 29 15:26:46 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 03:14:24 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b6a5a318
tests/emerge: test_simple.py, conftest.py: Refactor
Refactor.
Removed some dead code.
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 | 458 +-------------------------------
lib/portage/tests/emerge/test_simple.py | 139 +---------
2 files changed, 13 insertions(+), 584 deletions(-)
diff --git a/lib/portage/tests/emerge/conftest.py
b/lib/portage/tests/emerge/conftest.py
index 5bf535cdcf..43fde441fd 100644
--- a/lib/portage/tests/emerge/conftest.py
+++ b/lib/portage/tests/emerge/conftest.py
@@ -178,7 +178,7 @@ _INSTALLED_EBUILDS = {
},
}
-_SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE = [
+_BASELINE_COMMAND_FETCHCOMMAND_SEQUENCE = [
# "mv {pkgdir} {binhost_dir}",
"emerge -eG dev-libs/A",
# "rm -R {pkgdir}",
@@ -190,7 +190,7 @@ _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE = [
# "mv {binhost_dir} {pkgdir}",
]
-_SIMPLE_COMMAND_SEQUENCE = [
+_BASELINE_COMMAND_SEQUENCE = [
"emerge -1 dev-libs/A -v dev-libs/B",
"emerge --root --quickpkg-direct-root",
"emerge --quickpkg-direct-root",
@@ -277,14 +277,14 @@ _SIMPLE_COMMAND_SEQUENCE = [
"EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B",
"ROOT={cross_root} emerge dev-libs/B",
"portageq has_version {cross_eroot} dev-libs/B",
-] + _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE
+] + _BASELINE_COMMAND_FETCHCOMMAND_SEQUENCE
PORTAGE_PYTHON = portage._python_interpreter
NOOP = lambda: ...
class PortageCommand:
- """A class that represents a simple test case command,
+ """A class that represents a baseline test case command,
including handling of environment and one-use arguments.
"""
@@ -429,15 +429,10 @@ class Regenworld(PortageCommand):
)
-class Rm(PortageCommand):
- name = "rm"
- command = (find_binary(name),)
-
-
def pytest_generate_tests(metafunc):
if "baseline_command" in metafunc.fixturenames:
metafunc.parametrize(
- "baseline_command", _SIMPLE_COMMAND_SEQUENCE, indirect=True
+ "baseline_command", _BASELINE_COMMAND_SEQUENCE, indirect=True
)
@@ -523,414 +518,6 @@ def binhost(playground, async_loop):
binhost_server.__exit__(None, None, None)
[email protected]()
-def _generate_all_simple_commands(
- playground,
- binhost,
- emerge,
- env_update,
- portageq,
- etc_update,
- dispatch_conf,
- ebuild,
- egencache,
- emaint,
- fixpackages,
- quickpkg,
- regenworld,
-):
- """This fixture generates all the commands that
- ``test_portage_baseline`` will use.
-
- But, don't use this fixture directly, instead, use the
- ``simple_command`` fixture. That improves performance a bit due to
- pytest caching.
-
- .. note::
-
- To add a new command, define it in the local ``test_commands``
- dict, if not yet defined, and add its key at the correct position
- in the ``_SIMPLE_COMMAND_SEQUENCE`` list.
- """
- settings = playground.settings
- 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")
- cachedir = os.path.join(var_cache_edb, "dep")
- cachedir_pregen = os.path.join(test_repo_location, "metadata", "md5-cache")
-
- rm_binary = find_binary("rm")
- assert rm_binary is not None, "rm command not found"
- rm_cmd = (rm_binary,)
-
- egencache_extra_args = []
- if _have_python_xml():
- egencache_extra_args.append("--update-use-local-desc")
-
- test_ebuild = portdb.findname("dev-libs/A-1")
- assert test_ebuild is not None
-
- cross_prefix = os.path.join(eprefix, "cross_prefix")
- cross_root = os.path.join(eprefix, "cross_root")
- cross_eroot = os.path.join(cross_root, eprefix.lstrip(os.sep))
-
- binpkg_format = settings.get("BINPKG_FORMAT",
SUPPORTED_GENTOO_BINPKG_FORMATS[0])
- assert binpkg_format in ("xpak", "gpkg")
- if binpkg_format == "xpak":
- foo_filename = "foo-0-1.xpak"
- elif binpkg_format == "gpkg":
- foo_filename = "foo-0-1.gpkg.tar"
-
- test_commands = {}
-
- if hasattr(argparse.ArgumentParser, "parse_intermixed_args"):
- parse_intermixed_command = emerge + (
- "--oneshot",
- "dev-libs/A",
- "-v",
- "dev-libs/A",
- )
- else:
- parse_intermixed_command = NOOP
- test_commands["emerge -1 dev-libs/A -v dev-libs/B"] =
parse_intermixed_command
-
- test_commands["emerge --root --quickpkg-direct-root"] = emerge + (
- "--usepkgonly",
- "--root",
- cross_root,
- "--quickpkg-direct=y",
- "--quickpkg-direct-root",
- "/",
- "dev-libs/A",
- )
- test_commands["emerge --quickpkg-direct-root"] = emerge + (
- "--usepkgonly",
- "--quickpkg-direct=y",
- "--quickpkg-direct-root",
- cross_root,
- "dev-libs/A",
- )
- test_commands["env-update"] = env_update
- test_commands["portageq envvar"] = portageq + (
- "envvar",
- "-v",
- "CONFIG_PROTECT",
- "EROOT",
- "PORTAGE_CONFIGROOT",
- "PORTAGE_TMPDIR",
- "USERLAND",
- )
- test_commands["etc-update"] = etc_update
- test_commands["dispatch-conf"] = dispatch_conf
- test_commands["emerge --version"] = emerge + ("--version",)
- test_commands["emerge --info"] = emerge + ("--info",)
- test_commands["emerge --info --verbose"] = emerge + ("--info", "--verbose")
- test_commands["emerge --list-sets"] = emerge + ("--list-sets",)
- test_commands["emerge --check-news"] = emerge + ("--check-news",)
- test_commands["rm -rf {cachedir}"] = rm_cmd + ("-rf", cachedir)
- test_commands["rm -rf {cachedir_pregen}"] = rm_cmd + ("-rf",
cachedir_pregen)
- test_commands["emerge --regen"] = emerge + ("--regen",)
- test_commands["FEATURES=metadata-transfer emerge --regen"] = (
- ({"FEATURES": "metadata-transfer"},) + emerge + ("--regen",)
- )
- test_commands["egencache --update"] = (
- egencache + ("--update",) + tuple(egencache_extra_args)
- )
- test_commands["FEATURES=metadata-transfer emerge --metadata"] = (
- ({"FEATURES": "metadata-transfer"},) + emerge + ("--metadata",)
- )
- test_commands["emerge --metadata"] = emerge + ("--metadata",)
-
- test_commands["emerge --oneshot virtual/foo"] = emerge + (
- "--oneshot",
- "virtual/foo",
- )
- 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 + ("--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 + (
- "--pretend",
- "dev-libs/A",
- )
-
- test_commands["ebuild dev-libs/A-1 manifest clean package merge"] = ebuild
+ (
- test_ebuild,
- "manifest",
- "clean",
- "package",
- "merge",
- )
- test_commands["emerge --pretend --tree --complete-graph dev-libs/A"] =
emerge + (
- "--pretend",
- "--tree",
- "--complete-graph",
- "dev-libs/A",
- )
- test_commands["emerge -p dev-libs/B"] = emerge + ("-p", "dev-libs/B")
- test_commands["emerge -p --newrepo dev-libs/B"] = emerge + (
- "-p",
- "--newrepo",
- "dev-libs/B",
- )
- test_commands["emerge -B dev-libs/B"] = emerge + ("-B", "dev-libs/B")
- test_commands["emerge -1k dev-libs/B"] = emerge + (
- "--oneshot",
- "--usepkg",
- "dev-libs/B",
- )
- # trigger clean prior to pkg_pretend as in bug #390711
- test_commands["ebuild dev-libs/A-1 unpack"] = ebuild + (test_ebuild,
"unpack")
- test_commands["emerge -1 dev-libs/A"] = emerge + ("--oneshot",
"dev-libs/A")
- test_commands["emerge -n dev-libs/A"] = emerge + ("--noreplace",
"dev-libs/A")
- test_commands["emerge --config dev-libs/A"] = emerge + (
- "--config",
- "dev-libs/A",
- )
- test_commands["emerge --info dev-libs/A dev-libs/B"] = emerge + (
- "--info",
- "dev-libs/A",
- "dev-libs/B",
- )
- test_commands["emerge -pcv dev-libs/B"] = emerge + (
- "--pretend",
- "--depclean",
- "--verbose",
- "dev-libs/B",
- )
- test_commands["emerge -pc"] = emerge + ("--pretend", "--depclean")
- test_commands["emerge -c"] = emerge + ("--depclean",)
- test_commands["quickpkg --include-config y dev-libs/A"] = quickpkg + (
- "--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 + ("--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 + ("--check", "all")
- test_commands["emaint --fix all"] = emaint + ("--fix", "all")
- test_commands["fixpackages"] = fixpackages
- test_commands["regenworld"] = regenworld
- test_commands["portageq match {eroot} dev-libs/A"] = portageq + (
- "match",
- eroot,
- "dev-libs/A",
- )
- test_commands["portageq best_visible {eroot} dev-libs/A"] = portageq + (
- "best_visible",
- eroot,
- "dev-libs/A",
- )
- test_commands["portageq best_visible {eroot} binary dev-libs/A"] =
portageq + (
- "best_visible",
- eroot,
- "binary",
- "dev-libs/A",
- )
- test_commands["portageq contents {eroot} dev-libs/A-1"] = portageq + (
- "contents",
- eroot,
- "dev-libs/A-1",
- )
- test_commands[
- "portageq metadata {eroot} ebuild dev-libs/A-1 EAPI IUSE RDEPEND"
- ] = portageq + (
- "metadata",
- eroot,
- "ebuild",
- "dev-libs/A-1",
- "EAPI",
- "IUSE",
- "RDEPEND",
- )
- test_commands[
- "portageq metadata {eroot} binary dev-libs/A-1 EAPI USE RDEPEND"
- ] = portageq + (
- "metadata",
- eroot,
- "binary",
- "dev-libs/A-1",
- "EAPI",
- "USE",
- "RDEPEND",
- )
- test_commands[
- "portageq metadata {eroot} installed dev-libs/A-1 EAPI USE RDEPEND"
- ] = portageq + (
- "metadata",
- eroot,
- "installed",
- "dev-libs/A-1",
- "EAPI",
- "USE",
- "RDEPEND",
- )
- test_commands["portageq owners {eroot} {eroot}usr"] = portageq + (
- "owners",
- eroot,
- eroot + "usr",
- )
- test_commands["emerge -p {eroot}usr"] = emerge + ("-p", eroot + "usr")
- test_commands["emerge -pCq {eroot}usr"] = emerge + (
- "-p",
- "--unmerge",
- "-q",
- eroot + "usr",
- )
- test_commands["emerge -Cq dev-libs/A"] = emerge + (
- "--unmerge",
- "--quiet",
- "dev-libs/A",
- )
- test_commands["emerge -Cq dev-libs/B"] = emerge + (
- "-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
- + ("--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 + (
- "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 + ("dev-libs/C",)
- )
- test_commands[
- "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/C"
- ] = (
- ({"EPREFIX": cross_prefix},)
- + portageq
- + ("has_version", cross_prefix, "dev-libs/C")
- )
- test_commands[
- "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/D"
- ] = (
- ({"EPREFIX": cross_prefix},)
- + portageq
- + ("has_version", cross_prefix, "dev-libs/D")
- )
- test_commands["ROOT={cross_root} emerge dev-libs/D"] = (
- ({"ROOT": cross_root},) + emerge + ("dev-libs/D",)
- )
- test_commands["portageq has_version {cross_eroot} dev-libs/D"] = portageq
+ (
- "has_version",
- cross_eroot,
- "dev-libs/D",
- )
- # EAPI 5
- test_commands["EPREFIX={cross_prefix} emerge -K dev-libs/A"] = (
- ({"EPREFIX": cross_prefix},) + emerge + ("--usepkgonly", "dev-libs/A")
- )
- test_commands[
- "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/A"
- ] = (
- ({"EPREFIX": cross_prefix},)
- + portageq
- + ("has_version", cross_prefix, "dev-libs/A")
- )
- test_commands[
- "EPREFIX={cross_prefix} portageq has_version {cross_prefix} dev-libs/B"
- ] = (
- ({"EPREFIX": cross_prefix},)
- + portageq
- + ("has_version", cross_prefix, "dev-libs/B")
- )
- test_commands["EPREFIX={cross_prefix} emerge -Cq dev-libs/B"] = (
- ({"EPREFIX": cross_prefix},) + emerge + ("-C", "--quiet", "dev-libs/B")
- )
- test_commands["EPREFIX={cross_prefix} emerge -Cq dev-libs/A"] = (
- ({"EPREFIX": cross_prefix},) + emerge + ("-C", "--quiet", "dev-libs/A")
- )
- test_commands["EPREFIX={cross_prefix} emerge dev-libs/A"] = (
- ({"EPREFIX": cross_prefix},) + emerge + ("dev-libs/A",)
- )
-
- # Test ROOT support
- test_commands["ROOT={cross_root} emerge dev-libs/B"] = (
- ({"ROOT": cross_root},) + emerge + ("dev-libs/B",)
- )
- test_commands["portageq has_version {cross_eroot} dev-libs/B"] = portageq
+ (
- "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 _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE:
- test_commands[command_name] = NOOP
- else:
- test_commands["mv {pkgdir} {binhost_dir}"] = lambda: os.rename(
- pkgdir, binhost_dir
- )
- test_commands["emerge -eG dev-libs/A"] = emerge + (
- "-e",
- "--getbinpkgonly",
- "dev-libs/A",
- )
- test_commands["rm -R {pkgdir}"] = 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["PORTAGE_BINHOST={binhost_uri} emerge -feG dev-libs/A"]
= (
- ({"PORTAGE_BINHOST": binhost_uri},)
- + emerge
- + ("-fe", "--getbinpkgonly", "dev-libs/A")
- )
-
- yield test_commands
-
-
@pytest.fixture()
def _generate_all_baseline_commands(playground, binhost):
"""This fixture generates all the commands that
@@ -944,7 +531,7 @@ def _generate_all_baseline_commands(playground, binhost):
To add a new command, define it in the local ``test_commands``
dict, if not yet defined, and add its key at the correct position
- in the ``_SIMPLE_COMMAND_SEQUENCE`` list.
+ in the ``_BASELINE_COMMAND_SEQUENCE`` list.
"""
settings = playground.settings
eprefix = settings["EPREFIX"]
@@ -1027,9 +614,6 @@ def _generate_all_baseline_commands(playground, binhost):
test_commands["emerge --list-sets"] = Emerge("--list-sets")
test_commands["emerge --check-news"] = Emerge("--check-news")
- # test_commands["rm -rf {cachedir}"] = Rm("-rf", cachedir)
- # test_commands["rm -rf {cachedir_pregen}"] = Rm("-rf", cachedir_pregen)
-
def _rm_cachedir():
shutil.rmtree(cachedir)
@@ -1140,6 +724,10 @@ def _generate_all_baseline_commands(playground, binhost):
test_commands["emerge -c"] = Emerge(
"--depclean",
)
+
+ # Test bug #523684, where a file renamed or removed by the
+ # admin forces replacement files to be merged with config
+ # protection.
test_commands["quickpkg --include-config y dev-libs/A"] = Quickpkg(
"--include-config",
"y",
@@ -1148,13 +736,6 @@ def _generate_all_baseline_commands(playground, binhost):
0, eroot, settings["CONFIG_PROTECT"]
),
)
- # 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(
@@ -1169,10 +750,6 @@ def _generate_all_baseline_commands(playground, binhost):
),
)
- # test_commands["one protected file"] = lambda:
_check_number_of_protected_files(
- # 1, eroot, settings["CONFIG_PROTECT"]
- # )
-
test_commands["emaint --check all"] = Emaint("--check", "all")
test_commands["emaint --fix all"] = Emaint("--fix", "all")
test_commands["fixpackages"] = Fixpackages()
@@ -1351,7 +928,7 @@ def _generate_all_baseline_commands(playground, binhost):
fetchcommand = portage.util.shlex_split(settings["FETCHCOMMAND"])
fetch_bin = portage.process.find_binary(fetchcommand[0])
if fetch_bin is None:
- for command_name in _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE:
+ for command_name in _BASELINE_COMMAND_FETCHCOMMAND_SEQUENCE:
test_commands[command_name] = Noop()
else:
# test_commands["mv {pkgdir} {binhost_dir}"] = lambda: os.rename(
@@ -1386,22 +963,11 @@ def _generate_all_baseline_commands(playground, binhost):
yield test_commands
[email protected]()
-def simple_command(request, _generate_all_simple_commands):
- """A fixture that provides the commands to perform a baseline
- functional test of portage. It uses another fixture, namely
- ``_generate_all_simple_commands``.
- Pytest caches the fixtures and there is a little performance
- improvement if the commands are generated only once..
- """
- return _generate_all_simple_commands[request.param]
-
-
@pytest.fixture()
def baseline_command(request, _generate_all_baseline_commands):
"""A fixture that provides the commands to perform a baseline
functional test of portage. It uses another fixture, namely
- ``_generate_all_simple_commands``.
+ ``_generate_all_baseline_commands``.
Pytest caches the fixtures and there is a little performance
improvement if the commands are generated only once..
"""
diff --git a/lib/portage/tests/emerge/test_simple.py
b/lib/portage/tests/emerge/test_simple.py
index d287aaa159..b23e10ddfd 100644
--- a/lib/portage/tests/emerge/test_simple.py
+++ b/lib/portage/tests/emerge/test_simple.py
@@ -60,24 +60,17 @@ move dev-util/git dev-vcs/git
def test_portage_baseline(async_loop, playground, binhost, baseline_command):
async_loop.run_until_complete(
asyncio.ensure_future(
- # _async_test_baseline(
- # playground,
- # binhost,
- # simple_command,
- # ),
_async_test_simple(
playground,
binhost,
- # simple_command,
baseline_command,
- loop=async_loop,
),
loop=async_loop,
)
)
-async def _async_test_simple(playground, binhost, commands, loop):
+async def _async_test_simple(playground, binhost, commands):
debug = playground.debug
settings = playground.settings
trees = playground.trees
@@ -199,27 +192,14 @@ async def _async_test_simple(playground, binhost,
commands, loop):
# triggered by python -Wd will be visible.
stdout = subprocess.PIPE
- # # command.prepare()
- # if hasattr(command, "__call__"):
- # command()
- # return
for command in commands:
if command:
command.base_environment = env
- # if isinstance(command[0], dict):
- # local_env = env.copy()
- # local_env.update(command[0])
- # command = command[1:]
- # else:
- # local_env = env
- # with self.subTest(cmd=command, i=idx):
proc = await asyncio.create_subprocess_exec(
*command(), env=command.env, stderr=None, stdout=stdout
)
- # command.cleanup()
-
if debug:
await proc.wait()
else:
@@ -234,120 +214,3 @@ async def _async_test_simple(playground, binhost,
commands, loop):
os.EX_OK == proc.returncode
), f"'{real_command}' failed with args '{args}'"
command.check_command_result()
-
-
-async def _async_test_baseline(playground, binhost, baseline_command):
- debug = playground.debug
- settings = playground.settings
- trees = playground.trees
- eprefix = settings["EPREFIX"]
-
- # test_commands = make_test_commands(settings, trees, binhost["uri"])
-
- test_repo_location = settings.repositories["test_repo"].location
- var_cache_edb = os.path.join(eprefix, "var", "cache", "edb")
- cachedir = os.path.join(var_cache_edb, "dep")
- cachedir_pregen = os.path.join(test_repo_location, "metadata", "md5-cache")
-
- cross_prefix = os.path.join(eprefix, "cross_prefix")
- cross_root = os.path.join(eprefix, "cross_root")
- cross_eroot = os.path.join(cross_root, eprefix.lstrip(os.sep))
-
- distdir = playground.distdir
- pkgdir = playground.pkgdir
- fake_bin = os.path.join(eprefix, "bin")
- portage_tmpdir = os.path.join(eprefix, "var", "tmp", "portage")
- profile_path = settings.profile_path
- user_config_dir = os.path.join(os.sep, eprefix, USER_CONFIG_PATH)
-
- path = os.environ.get("PATH")
- if path is not None and not path.strip():
- path = None
- if path is None:
- path = ""
- else:
- path = ":" + path
- path = fake_bin + path
-
- pythonpath = os.environ.get("PYTHONPATH")
- if pythonpath is not None and not pythonpath.strip():
- pythonpath = None
- if pythonpath is not None and pythonpath.split(":")[0] == PORTAGE_PYM_PATH:
- pass
- else:
- if pythonpath is None:
- pythonpath = ""
- else:
- pythonpath = ":" + pythonpath
- pythonpath = PORTAGE_PYM_PATH + pythonpath
-
- env = {
- "PORTAGE_OVERRIDE_EPREFIX": eprefix,
- "CLEAN_DELAY": "0",
- "DISTDIR": distdir,
- "EMERGE_WARNING_DELAY": "0",
- "INFODIR": "",
- "INFOPATH": "",
- "PATH": path,
- "PKGDIR": pkgdir,
- "PORTAGE_INST_GID": str(os.getgid()), # str(portage.data.portage_gid),
- "PORTAGE_INST_UID": str(os.getuid()), # str(portage.data.portage_uid),
- "PORTAGE_PYTHON": portage._python_interpreter,
- "PORTAGE_REPOSITORIES": settings.repositories.config_string(),
- "PORTAGE_TMPDIR": portage_tmpdir,
- "PORTAGE_LOGDIR": portage_tmpdir,
- "PYTHONDONTWRITEBYTECODE": os.environ.get("PYTHONDONTWRITEBYTECODE",
""),
- "PYTHONPATH": pythonpath,
- "__PORTAGE_TEST_PATH_OVERRIDE": fake_bin,
- }
-
- if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
- env["__PORTAGE_TEST_HARDLINK_LOCKS"] = os.environ[
- "__PORTAGE_TEST_HARDLINK_LOCKS"
- ]
-
- updates_dir = os.path.join(test_repo_location, "profiles", "updates")
- dirs = [
- cachedir,
- cachedir_pregen,
- cross_eroot,
- cross_prefix,
- distdir,
- fake_bin,
- portage_tmpdir,
- updates_dir,
- user_config_dir,
- var_cache_edb,
- ]
- etc_symlinks = ("dispatch-conf.conf", "etc-update.conf")
- # Override things that may be unavailable, or may have portability
- # issues when running tests in exotic environments.
- # prepstrip - bug #447810 (bash read builtin EINTR problem)
- true_symlinks = ["find", "prepstrip", "sed", "scanelf"]
- true_binary = find_binary("true")
- assert true_binary is not None, "true command not found"
-
- for d in dirs:
- ensure_dirs(d)
- for x in true_symlinks:
- try:
- os.symlink(true_binary, os.path.join(fake_bin, x))
- except FileExistsError:
- pass
- for x in etc_symlinks:
- 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
- with open(os.path.join(profile_path, "packages"), "w") as f:
- f.write("*dev-libs/token-system-pkg")
- for cp, xml_data in _METADATA_XML_FILES:
- with open(os.path.join(test_repo_location, cp, "metadata.xml"), "w")
as f:
- f.write(playground.metadata_xml_template % xml_data)
- with open(os.path.join(updates_dir, "1Q-2010"), "w") as f:
- f.write(_1Q_2010_UPDATE)
-
- baseline_command(environment=env)