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 E65A0158089 for ; Mon, 30 Oct 2023 03:14:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BF6472BC036; Mon, 30 Oct 2023 03:14:32 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 8A26F2BC036 for ; Mon, 30 Oct 2023 03:14:32 +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 9D0E9335C7A 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 23CB71300 for ; Mon, 30 Oct 2023 03:14:29 +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: <1698635664.ae5bb29328d709d1b5e5b9f8c8b3e4083a386716.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 X-VCS-Directories: lib/portage/tests/emerge/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ae5bb29328d709d1b5e5b9f8c8b3e4083a386716 X-VCS-Branch: master Date: Mon, 30 Oct 2023 03:14:29 +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: a86e641b-a0bc-4747-b6e9-082d7acb8252 X-Archives-Hash: 9dae98aa870a52bfff1a03939313be66 commit: ae5bb29328d709d1b5e5b9f8c8b3e4083a386716 Author: David Palao gmail com> AuthorDate: Fri Jul 7 16:06:20 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Oct 30 03:14:24 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ae5bb293 tests/emerge/conftest.py: Add a new fixture. Add a new fixture. It adds one more layer of indirection to the ``simple_command`` fixture. Quick benchmarks tell that it is faster due to pytest caching. Signed-off-by: David Palao gmail.com> Signed-off-by: Sam James gentoo.org> lib/portage/tests/emerge/conftest.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/portage/tests/emerge/conftest.py b/lib/portage/tests/emerge/conftest.py index 656ee85726..07895501d4 100644 --- a/lib/portage/tests/emerge/conftest.py +++ b/lib/portage/tests/emerge/conftest.py @@ -387,12 +387,19 @@ def binhost(playground, async_loop): @pytest.fixture() -def simple_command(playground, binhost, request): - """A fixture that provides the commands to perform a baseline - functional test of portage. +def _generate_all_simple_commands(playground, binhost): + """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. - To add a new command, define it in the local ``test_commands`` and - add its key to the ``_SIMPLE_COMMAND_SEQUENCE``. + .. 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"] @@ -822,4 +829,15 @@ def simple_command(playground, binhost, request): + ("-fe", "--getbinpkgonly", "dev-libs/A") ) - return test_commands[request.param] + yield test_commands + + +@pytest.fixture() +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]