From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BFD38158089 for ; Mon, 30 Oct 2023 03:14:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DEE362BC019; Mon, 30 Oct 2023 03:14:30 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BEADF2BC019 for ; Mon, 30 Oct 2023 03:14:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C64C5335C2E for ; Mon, 30 Oct 2023 03:14:29 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3BAB412F1 for ; Mon, 30 Oct 2023 03:14:28 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1698635661.95fb92aef6724394d65fa072c4109a4cc54ee3d3.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/emerge/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/tests/emerge/test_simple.py X-VCS-Directories: lib/portage/tests/emerge/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 95fb92aef6724394d65fa072c4109a4cc54ee3d3 X-VCS-Branch: master Date: Mon, 30 Oct 2023 03:14:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e36d77be-f40f-4c1e-84b6-cba44c80916f X-Archives-Hash: c968191d8f2030321f3c1eda53a98c17 commit: 95fb92aef6724394d65fa072c4109a4cc54ee3d3 Author: David Palao gmail com> AuthorDate: Fri Jun 9 15:19:35 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Oct 30 03:14:21 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=95fb92ae tests/emerge/test_simple.py: refactor function to make test commands Signed-off-by: David Palao gmail.com> Signed-off-by: Sam James gentoo.org> lib/portage/tests/emerge/test_simple.py | 92 +++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/lib/portage/tests/emerge/test_simple.py b/lib/portage/tests/emerge/test_simple.py index 1c7d1bafbe..35e221311e 100644 --- a/lib/portage/tests/emerge/test_simple.py +++ b/lib/portage/tests/emerge/test_simple.py @@ -223,32 +223,9 @@ class BinhostContentMap(Mapping): raise KeyError(request_path) -@pytest.mark.parametrize("binpkg_format", SUPPORTED_GENTOO_BINPKG_FORMATS) -def test_simple_emerge(binpkg_format): - playground = ResolverPlayground( - ebuilds=_AVAILABLE_EBUILDS, - installed=_INSTALLED_EBUILDS, - debug=False, - user_config={ - "make.conf": (f'BINPKG_FORMAT="{binpkg_format}"',), - }, - ) - - loop = asyncio._wrap_loop() - loop.run_until_complete( - asyncio.ensure_future( - _async_test_simple(playground, _METADATA_XML_FILES, loop=loop), - loop=loop, - ) - ) - - -async def _async_test_simple(playground, metadata_xml_files, loop): - debug = playground.debug - settings = playground.settings +def make_test_commands(settings, trees, binhost_uri): eprefix = settings["EPREFIX"] eroot = settings["EROOT"] - trees = playground.trees portdb = trees[eroot]["porttree"].dbapi test_repo_location = settings.repositories["test_repo"].location var_cache_edb = os.path.join(eprefix, "var", "cache", "edb") @@ -322,18 +299,6 @@ async def _async_test_simple(playground, metadata_xml_files, loop): cross_root = os.path.join(eprefix, "cross_root") cross_eroot = os.path.join(cross_root, eprefix.lstrip(os.sep)) - binhost_dir = os.path.join(eprefix, "binhost") - binhost_address = "127.0.0.1" - binhost_remote_path = "/binhost" - binhost_server = AsyncHTTPServer( - binhost_address, BinhostContentMap(binhost_remote_path, binhost_dir), loop - ).__enter__() - binhost_uri = "http://{address}:{port}{path}".format( - address=binhost_address, - port=binhost_server.server_port, - path=binhost_remote_path, - ) - binpkg_format = settings.get("BINPKG_FORMAT", SUPPORTED_GENTOO_BINPKG_FORMATS[0]) assert binpkg_format in ("xpak", "gpkg") if binpkg_format == "xpak": @@ -554,7 +519,7 @@ async def _async_test_simple(playground, metadata_xml_files, loop): 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(playground.settings["FETCHCOMMAND"]) + 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 + ( @@ -571,6 +536,56 @@ async def _async_test_simple(playground, metadata_xml_files, loop): lambda: shutil.rmtree(pkgdir), lambda: os.rename(binhost_dir, pkgdir), ) + return test_commands + + +@pytest.mark.parametrize("binpkg_format", SUPPORTED_GENTOO_BINPKG_FORMATS) +def test_simple_emerge(binpkg_format): + playground = ResolverPlayground( + ebuilds=_AVAILABLE_EBUILDS, + installed=_INSTALLED_EBUILDS, + debug=False, + user_config={ + "make.conf": (f'BINPKG_FORMAT="{binpkg_format}"',), + }, + ) + + loop = asyncio._wrap_loop() + loop.run_until_complete( + asyncio.ensure_future( + _async_test_simple(playground, _METADATA_XML_FILES, loop=loop), + loop=loop, + ) + ) + + +async def _async_test_simple(playground, metadata_xml_files, loop): + debug = playground.debug + settings = playground.settings + trees = playground.trees + eprefix = settings["EPREFIX"] + binhost_dir = os.path.join(eprefix, "binhost") + binhost_address = "127.0.0.1" + binhost_remote_path = "/binhost" + binhost_server = AsyncHTTPServer( + binhost_address, BinhostContentMap(binhost_remote_path, binhost_dir), loop + ).__enter__() + binhost_uri = "http://{address}:{port}{path}".format( + address=binhost_address, + port=binhost_server.server_port, + path=binhost_remote_path, + ) + + 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 @@ -611,7 +626,7 @@ async def _async_test_simple(playground, metadata_xml_files, loop): "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, + "PORTAGE_PYTHON": portage._python_interpreter, "PORTAGE_REPOSITORIES": settings.repositories.config_string(), "PORTAGE_TMPDIR": portage_tmpdir, "PORTAGE_LOGDIR": portage_tmpdir, @@ -667,7 +682,6 @@ slotmove =app-doc/pms-3 2 3 move dev-util/git dev-vcs/git """ ) - if debug: # The subprocess inherits both stdout and stderr, for # debugging purposes.