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 53136158089 for ; Mon, 30 Oct 2023 03:14:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 257162BC038; Mon, 30 Oct 2023 03:14:33 +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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 062902BC037 for ; Mon, 30 Oct 2023 03:14:33 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A5DE3335C8E for ; Mon, 30 Oct 2023 03:14:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EE1E712FE 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: <1698635663.33fd1883b4099965dd3f885ab8d8850b6ea6040c.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/conftest.py 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: 33fd1883b4099965dd3f885ab8d8850b6ea6040c 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: 46b6b07a-6e93-4633-8f61-a9b75108a834 X-Archives-Hash: 2bdbbaf2f83797e1a973933e89276115 commit: 33fd1883b4099965dd3f885ab8d8850b6ea6040c Author: David Palao gmail com> AuthorDate: Fri Jul 7 15:15:51 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Oct 30 03:14:23 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=33fd1883 tests/emerge: test_simple.py, conftest.py: Refactor Refactor: - _TEST_COMMAND_*NAMES -> _SIMPLE_COMMAND_*SEQUENCE - Added NOOP - defined global constant Signed-off-by: David Palao gmail.com> Signed-off-by: Sam James gentoo.org> lib/portage/tests/emerge/conftest.py | 53 +++++++++++++++++---------------- lib/portage/tests/emerge/test_simple.py | 12 ++++---- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/portage/tests/emerge/conftest.py b/lib/portage/tests/emerge/conftest.py index 7675d4c78c..9cb4691f56 100644 --- a/lib/portage/tests/emerge/conftest.py +++ b/lib/portage/tests/emerge/conftest.py @@ -177,26 +177,7 @@ _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 = [ +_SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE = [ "mv {pkgdir} {binhost_dir}", "emerge -eG dev-libs/A", "rm -R {pkgdir}", @@ -208,7 +189,7 @@ _TEST_COMMAND_NAMES_FETCHCOMMAND = [ "mv {binhost_dir} {pkgdir}", ] -_TEST_COMMAND_NAMES = [ +_SIMPLE_COMMAND_SEQUENCE = [ "emerge -1 dev-libs/A -v dev-libs/B", "emerge --root --quickpkg-direct-root", "emerge --quickpkg-direct-root", @@ -295,12 +276,32 @@ _TEST_COMMAND_NAMES = [ "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", -] + _TEST_COMMAND_NAMES_FETCHCOMMAND +] + _SIMPLE_COMMAND_FETCHCOMMAND_SEQUENCE + +NOOP = lambda: ... + + +# 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): +# ... def pytest_generate_tests(metafunc): if "simple_command" in metafunc.fixturenames: - metafunc.parametrize("simple_command", _TEST_COMMAND_NAMES, indirect=True) + metafunc.parametrize("simple_command", _SIMPLE_COMMAND_SEQUENCE, indirect=True) def _have_python_xml(): @@ -482,7 +483,7 @@ def simple_command(playground, binhost, request): "dev-libs/A", ) else: - parse_intermixed_command = lambda: ... + 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_cmd + ( @@ -792,8 +793,8 @@ def simple_command(playground, binhost, request): 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: ... + 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 diff --git a/lib/portage/tests/emerge/test_simple.py b/lib/portage/tests/emerge/test_simple.py index 692c6a9cb4..12a16f2d93 100644 --- a/lib/portage/tests/emerge/test_simple.py +++ b/lib/portage/tests/emerge/test_simple.py @@ -32,6 +32,11 @@ _METADATA_XML_FILES = ( ), ) +_1Q_2010_UPDATE = """ +slotmove =app-doc/pms-3 2 3 +move dev-util/git dev-vcs/git +""" + @pytest.mark.ft def test_simple_emerge(async_loop, playground, binhost, simple_command): @@ -161,12 +166,7 @@ async def _async_test_simple(playground, binhost, command, metadata_xml_files, l 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( - """ -slotmove =app-doc/pms-3 2 3 -move dev-util/git dev-vcs/git -""" - ) + f.write(_1Q_2010_UPDATE) if debug: # The subprocess inherits both stdout and stderr, for # debugging purposes.