public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/ebuild/
Date: Mon, 30 Oct 2023 05:09:42 +0000 (UTC)	[thread overview]
Message-ID: <1698641275.6a7297abca88c5d86ac299e51a52547baac791f1.zmedico@gentoo> (raw)

commit:     6a7297abca88c5d86ac299e51a52547baac791f1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 30 04:43:42 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 04:47:55 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a7297ab

test_doebuild_fd_pipes.py: multiprocessing spawn compat

Use multiprocessing.Pipe for compatibility with the spawn
start method. Also pass QueryCommand._db to the child
process, like MergeProcess does.

Bug: https://bugs.gentoo.org/916247
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/tests/ebuild/test_doebuild_fd_pipes.py | 30 ++++++++++++++--------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py
index 51ddc23908..678486ed16 100644
--- a/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py
+++ b/lib/portage/tests/ebuild/test_doebuild_fd_pipes.py
@@ -1,6 +1,8 @@
 # Copyright 2013-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
+import multiprocessing
+
 import portage
 from portage import os
 from portage.tests import TestCase
@@ -13,6 +15,8 @@ from _emerge.PipeReader import PipeReader
 
 
 class DoebuildFdPipesTestCase(TestCase):
+    output_fd = 200
+
     def testDoebuild(self):
         """
         Invoke portage.doebuild() with the fd_pipes parameter, and
@@ -21,7 +25,7 @@ class DoebuildFdPipesTestCase(TestCase):
         supported for API consumers (see bug #475812).
         """
 
-        output_fd = 200
+        output_fd = self.output_fd
         ebuild_body = ["S=${WORKDIR}"]
         for phase_func in (
             "pkg_info",
@@ -117,21 +121,19 @@ class DoebuildFdPipesTestCase(TestCase):
                 "clean",
                 "merge",
             ):
-                pr, pw = os.pipe()
+                pr, pw = multiprocessing.Pipe(duplex=False)
 
                 producer = ForkProcess(
-                    target=portage.doebuild,
-                    args=(ebuildpath, phase),
+                    target=self._doebuild,
+                    fd_pipes={
+                        1: dev_null.fileno(),
+                    },
+                    args=(QueryCommand._db, pw, ebuildpath, phase),
                     kwargs={
                         "settings": settings,
                         "mydbapi": portdb,
                         "tree": "porttree",
                         "vartree": root_config.trees["vartree"],
-                        "fd_pipes": {
-                            1: dev_null.fileno(),
-                            2: dev_null.fileno(),
-                            output_fd: pw,
-                        },
                         "prev_mtimes": {},
                     },
                 )
@@ -144,7 +146,7 @@ class DoebuildFdPipesTestCase(TestCase):
                     task_scheduler.start()
                 finally:
                     # PipeReader closes pr
-                    os.close(pw)
+                    pw.close()
 
                 task_scheduler.wait()
                 output = portage._unicode_decode(consumer.getvalue()).rstrip("\n")
@@ -161,3 +163,11 @@ class DoebuildFdPipesTestCase(TestCase):
             dev_null.close()
             playground.cleanup()
             QueryCommand._db = None
+
+    @staticmethod
+    def _doebuild(db, pw, *args, **kwargs):
+        QueryCommand._db = db
+        kwargs["fd_pipes"] = {
+            DoebuildFdPipesTestCase.output_fd: pw.fileno(),
+        }
+        return portage.doebuild(*args, **kwargs)


             reply	other threads:[~2023-10-30  5:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30  5:09 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-12-31  0:01 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/ebuild/ Zac Medico
2023-12-05  6:11 Zac Medico
2021-05-24  6:20 Zac Medico
2021-02-21  8:33 Zac Medico
2020-08-03 23:28 Zac Medico
2020-07-19 21:55 Zac Medico
2020-03-22  1:12 Zac Medico
2019-10-19 23:15 Zac Medico
2019-10-19  5:29 Zac Medico
2019-10-19  1:38 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=1698641275.6a7297abca88c5d86ac299e51a52547baac791f1.zmedico@gentoo \
    --to=zmedico@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