public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/pkgcheck/, dev-util/pkgcheck/files/
Date: Sat, 31 Dec 2022 11:32:34 +0000 (UTC)	[thread overview]
Message-ID: <1672486219.10717ac4ea34a89ed60d1d0d118c491102de9862.arthurzam@gentoo> (raw)

commit:     10717ac4ea34a89ed60d1d0d118c491102de9862
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 31 11:30:19 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 11:30:19 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10717ac4

dev-util/pkgcheck: fix missing bin/ for replay test

Closes: https://bugs.gentoo.org/888896
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .../files/pkgcheck-0.10.20-fix-replay-bin.patch    | 109 +++++++++++++++++++++
 dev-util/pkgcheck/pkgcheck-0.10.20.ebuild          |   4 +
 2 files changed, 113 insertions(+)

diff --git a/dev-util/pkgcheck/files/pkgcheck-0.10.20-fix-replay-bin.patch b/dev-util/pkgcheck/files/pkgcheck-0.10.20-fix-replay-bin.patch
new file mode 100644
index 000000000000..e20c0b3f53f5
--- /dev/null
+++ b/dev-util/pkgcheck/files/pkgcheck-0.10.20-fix-replay-bin.patch
@@ -0,0 +1,109 @@
+test_pkgcheck_replay: fix test_replay_pipe_stdin from sdist
+
+Bug: https://bugs.gentoo.org/888896
+Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
+--- a/tests/scripts/test_pkgcheck_replay.py
++++ b/tests/scripts/test_pkgcheck_replay.py
+@@ -1,20 +1,18 @@
+-import os
+-import subprocess
+ import tempfile
+ from functools import partial
+ from unittest.mock import patch
+
+ import pytest
++from snakeoil.formatters import PlainTextFormatter
++
+ from pkgcheck import __title__ as project
+ from pkgcheck.checks.profiles import ProfileWarning
+ from pkgcheck.reporters import JsonStream
+ from pkgcheck.scripts import run
+-from snakeoil.formatters import PlainTextFormatter
+
+
+ class TestPkgcheckReplay:
+-
+-    script = partial(run, project)
++    script = staticmethod(partial(run, project))
+
+     @pytest.fixture(autouse=True)
+     def _setup(self, testconfig):
+@@ -33,11 +31,11 @@ class TestPkgcheckReplay:
+
+     def test_replay(self, capsys):
+         result = ProfileWarning("profile warning: foo")
+-        with tempfile.NamedTemporaryFile() as f:
+-            out = PlainTextFormatter(f)
++        with tempfile.NamedTemporaryFile() as file:
++            out = PlainTextFormatter(file)
+             with JsonStream(out) as reporter:
+                 reporter.report(result)
+-            with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]):
++            with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]):
+                 with pytest.raises(SystemExit) as excinfo:
+                     self.script()
+                 out, err = capsys.readouterr()
+@@ -47,13 +45,13 @@ class TestPkgcheckReplay:
+
+     def test_corrupted_resuts(self, capsys):
+         result = ProfileWarning("profile warning: foo")
+-        with tempfile.NamedTemporaryFile() as f:
+-            out = PlainTextFormatter(f)
++        with tempfile.NamedTemporaryFile() as file:
++            out = PlainTextFormatter(file)
+             with JsonStream(out) as reporter:
+                 reporter.report(result)
+-            f.write(b"corrupted")
+-            f.seek(0)
+-            with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]):
++            file.write(b"corrupted")
++            file.seek(0)
++            with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]):
+                 with pytest.raises(SystemExit) as excinfo:
+                     self.script()
+                 out, err = capsys.readouterr()
+@@ -61,26 +59,28 @@ class TestPkgcheckReplay:
+                 assert excinfo.value.code == 2
+
+     def test_invalid_file(self, capsys):
+-        with tempfile.NamedTemporaryFile(mode="wt") as f:
+-            f.write("invalid file")
+-            f.seek(0)
+-            with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]):
++        with tempfile.NamedTemporaryFile(mode="wt") as file:
++            file.write("invalid file")
++            file.seek(0)
++            with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]):
+                 with pytest.raises(SystemExit) as excinfo:
+                     self.script()
+                 out, err = capsys.readouterr()
+                 assert err.strip() == "pkgcheck replay: error: invalid or unsupported replay file"
+                 assert excinfo.value.code == 2
+
+-    def test_replay_pipe_stdin(self):
+-        script = pytest.REPO_ROOT / "bin/pkgcheck"
+-        result = ProfileWarning("profile warning: foo")
+-        with tempfile.NamedTemporaryFile() as f:
+-            out = PlainTextFormatter(f)
++    def test_replay_pipe_stdin(self, capsys):
++        with tempfile.NamedTemporaryFile() as file:
++            out = PlainTextFormatter(file)
+             with JsonStream(out) as reporter:
+-                reporter.report(result)
+-            f.seek(0)
+-            p = subprocess.run(
+-                [script, "replay", "-R", "StrReporter", "-"], stdin=f, stdout=subprocess.PIPE
+-            )
+-            assert p.stdout.decode() == "profile warning: foo\n"
+-            assert p.returncode == 0
++                reporter.report(ProfileWarning("profile warning: foo"))
++            file.seek(0)
++
++            with open(file.name) as stdin, patch("sys.stdin", stdin), patch(
++                "sys.argv", [*self.args, "-R", "StrReporter", "-"]
++            ), pytest.raises(SystemExit) as excinfo:
++                self.script()
++            out, err = capsys.readouterr()
++            assert not err
++            assert out == "profile warning: foo\n"
++            assert excinfo.value.code == 0

diff --git a/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild b/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild
index 45516db85496..c3d2532fb01c 100644
--- a/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild
+++ b/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild
@@ -55,6 +55,10 @@ BDEPEND="${RDEPEND}
 	)
 "
 
+PATCHES=(
+	"${FILESDIR}/${P}-fix-replay-bin.patch"
+)
+
 SITEFILE="50${PN}-gentoo.el"
 
 distutils_enable_tests pytest


             reply	other threads:[~2022-12-31 11:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-31 11:32 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-03-04 18:23 [gentoo-commits] repo/gentoo:master commit in: dev-util/pkgcheck/, dev-util/pkgcheck/files/ Arthur Zamarin
2023-02-03 12:52 Arthur Zamarin
2022-08-01 20:39 Sam James
2021-08-25 16:55 Michał Górny
2021-05-09  9:13 Michał Górny

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=1672486219.10717ac4ea34a89ed60d1d0d118c491102de9862.arthurzam@gentoo \
    --to=arthurzam@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