1 |
commit: 10717ac4ea34a89ed60d1d0d118c491102de9862 |
2 |
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 31 11:30:19 2022 +0000 |
4 |
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 31 11:30:19 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10717ac4 |
7 |
|
8 |
dev-util/pkgcheck: fix missing bin/ for replay test |
9 |
|
10 |
Closes: https://bugs.gentoo.org/888896 |
11 |
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> |
12 |
|
13 |
.../files/pkgcheck-0.10.20-fix-replay-bin.patch | 109 +++++++++++++++++++++ |
14 |
dev-util/pkgcheck/pkgcheck-0.10.20.ebuild | 4 + |
15 |
2 files changed, 113 insertions(+) |
16 |
|
17 |
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 |
18 |
new file mode 100644 |
19 |
index 000000000000..e20c0b3f53f5 |
20 |
--- /dev/null |
21 |
+++ b/dev-util/pkgcheck/files/pkgcheck-0.10.20-fix-replay-bin.patch |
22 |
@@ -0,0 +1,109 @@ |
23 |
+test_pkgcheck_replay: fix test_replay_pipe_stdin from sdist |
24 |
+ |
25 |
+Bug: https://bugs.gentoo.org/888896 |
26 |
+Signed-off-by: Arthur Zamarin <arthurzam@g.o> |
27 |
+--- a/tests/scripts/test_pkgcheck_replay.py |
28 |
++++ b/tests/scripts/test_pkgcheck_replay.py |
29 |
+@@ -1,20 +1,18 @@ |
30 |
+-import os |
31 |
+-import subprocess |
32 |
+ import tempfile |
33 |
+ from functools import partial |
34 |
+ from unittest.mock import patch |
35 |
+ |
36 |
+ import pytest |
37 |
++from snakeoil.formatters import PlainTextFormatter |
38 |
++ |
39 |
+ from pkgcheck import __title__ as project |
40 |
+ from pkgcheck.checks.profiles import ProfileWarning |
41 |
+ from pkgcheck.reporters import JsonStream |
42 |
+ from pkgcheck.scripts import run |
43 |
+-from snakeoil.formatters import PlainTextFormatter |
44 |
+ |
45 |
+ |
46 |
+ class TestPkgcheckReplay: |
47 |
+- |
48 |
+- script = partial(run, project) |
49 |
++ script = staticmethod(partial(run, project)) |
50 |
+ |
51 |
+ @pytest.fixture(autouse=True) |
52 |
+ def _setup(self, testconfig): |
53 |
+@@ -33,11 +31,11 @@ class TestPkgcheckReplay: |
54 |
+ |
55 |
+ def test_replay(self, capsys): |
56 |
+ result = ProfileWarning("profile warning: foo") |
57 |
+- with tempfile.NamedTemporaryFile() as f: |
58 |
+- out = PlainTextFormatter(f) |
59 |
++ with tempfile.NamedTemporaryFile() as file: |
60 |
++ out = PlainTextFormatter(file) |
61 |
+ with JsonStream(out) as reporter: |
62 |
+ reporter.report(result) |
63 |
+- with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]): |
64 |
++ with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]): |
65 |
+ with pytest.raises(SystemExit) as excinfo: |
66 |
+ self.script() |
67 |
+ out, err = capsys.readouterr() |
68 |
+@@ -47,13 +45,13 @@ class TestPkgcheckReplay: |
69 |
+ |
70 |
+ def test_corrupted_resuts(self, capsys): |
71 |
+ result = ProfileWarning("profile warning: foo") |
72 |
+- with tempfile.NamedTemporaryFile() as f: |
73 |
+- out = PlainTextFormatter(f) |
74 |
++ with tempfile.NamedTemporaryFile() as file: |
75 |
++ out = PlainTextFormatter(file) |
76 |
+ with JsonStream(out) as reporter: |
77 |
+ reporter.report(result) |
78 |
+- f.write(b"corrupted") |
79 |
+- f.seek(0) |
80 |
+- with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]): |
81 |
++ file.write(b"corrupted") |
82 |
++ file.seek(0) |
83 |
++ with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]): |
84 |
+ with pytest.raises(SystemExit) as excinfo: |
85 |
+ self.script() |
86 |
+ out, err = capsys.readouterr() |
87 |
+@@ -61,26 +59,28 @@ class TestPkgcheckReplay: |
88 |
+ assert excinfo.value.code == 2 |
89 |
+ |
90 |
+ def test_invalid_file(self, capsys): |
91 |
+- with tempfile.NamedTemporaryFile(mode="wt") as f: |
92 |
+- f.write("invalid file") |
93 |
+- f.seek(0) |
94 |
+- with patch("sys.argv", self.args + ["-R", "StrReporter", f.name]): |
95 |
++ with tempfile.NamedTemporaryFile(mode="wt") as file: |
96 |
++ file.write("invalid file") |
97 |
++ file.seek(0) |
98 |
++ with patch("sys.argv", self.args + ["-R", "StrReporter", file.name]): |
99 |
+ with pytest.raises(SystemExit) as excinfo: |
100 |
+ self.script() |
101 |
+ out, err = capsys.readouterr() |
102 |
+ assert err.strip() == "pkgcheck replay: error: invalid or unsupported replay file" |
103 |
+ assert excinfo.value.code == 2 |
104 |
+ |
105 |
+- def test_replay_pipe_stdin(self): |
106 |
+- script = pytest.REPO_ROOT / "bin/pkgcheck" |
107 |
+- result = ProfileWarning("profile warning: foo") |
108 |
+- with tempfile.NamedTemporaryFile() as f: |
109 |
+- out = PlainTextFormatter(f) |
110 |
++ def test_replay_pipe_stdin(self, capsys): |
111 |
++ with tempfile.NamedTemporaryFile() as file: |
112 |
++ out = PlainTextFormatter(file) |
113 |
+ with JsonStream(out) as reporter: |
114 |
+- reporter.report(result) |
115 |
+- f.seek(0) |
116 |
+- p = subprocess.run( |
117 |
+- [script, "replay", "-R", "StrReporter", "-"], stdin=f, stdout=subprocess.PIPE |
118 |
+- ) |
119 |
+- assert p.stdout.decode() == "profile warning: foo\n" |
120 |
+- assert p.returncode == 0 |
121 |
++ reporter.report(ProfileWarning("profile warning: foo")) |
122 |
++ file.seek(0) |
123 |
++ |
124 |
++ with open(file.name) as stdin, patch("sys.stdin", stdin), patch( |
125 |
++ "sys.argv", [*self.args, "-R", "StrReporter", "-"] |
126 |
++ ), pytest.raises(SystemExit) as excinfo: |
127 |
++ self.script() |
128 |
++ out, err = capsys.readouterr() |
129 |
++ assert not err |
130 |
++ assert out == "profile warning: foo\n" |
131 |
++ assert excinfo.value.code == 0 |
132 |
|
133 |
diff --git a/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild b/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild |
134 |
index 45516db85496..c3d2532fb01c 100644 |
135 |
--- a/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild |
136 |
+++ b/dev-util/pkgcheck/pkgcheck-0.10.20.ebuild |
137 |
@@ -55,6 +55,10 @@ BDEPEND="${RDEPEND} |
138 |
) |
139 |
" |
140 |
|
141 |
+PATCHES=( |
142 |
+ "${FILESDIR}/${P}-fix-replay-bin.patch" |
143 |
+) |
144 |
+ |
145 |
SITEFILE="50${PN}-gentoo.el" |
146 |
|
147 |
distutils_enable_tests pytest |