From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/ebuild/, src/pkgcore/ebuild/
Date: Mon, 2 Jan 2023 20:03:25 +0000 (UTC) [thread overview]
Message-ID: <1672689427.e174fa3c960fef3ed6225fa9a43e14e0e11332b0.arthurzam@gentoo> (raw)
commit: e174fa3c960fef3ed6225fa9a43e14e0e11332b0
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 2 19:57:07 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jan 2 19:57:07 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=e174fa3c
domain: fix parsing of multiple USE_EXAPNDs
- add support for parsing of multiple USE_EXAPNDs
- fix error reporting when not USE_EXPAND has parsing error
- updates tests to catch warning thrown by parsing
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/ebuild/domain.py | 11 +++++++----
tests/ebuild/test_domain.py | 29 ++++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index 9fef5f843..0dba49d5d 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -92,13 +92,16 @@ def package_use_splitter(iterable):
def f(tokens: list[str]):
i = iter(tokens)
- for idx, x in enumerate(i):
- if x.endswith(":"):
+ for idx, flag in enumerate(i):
+ if flag.endswith(":"):
# we encountered `USE_EXPAND:` , thus all following tokens
# are values of that.
- x = x.lower()[:-1]
+ x = flag.lower()[:-1]
l = tokens[0:idx]
for flag in i:
+ if flag.endswith(":"):
+ x = flag.lower()[:-1]
+ continue
if flag.startswith("-"):
flag = f"-{x}_{flag[1:]}"
else:
@@ -107,7 +110,7 @@ def package_use_splitter(iterable):
raise ParseError(f"token {flag} is not a valid use flag")
l.append(flag)
return l
- elif not eapi_obj.is_valid_use_flag(x.lstrip("-")):
+ elif not eapi_obj.is_valid_use_flag(flag.lstrip("-")):
raise ParseError(f"token {flag} is not a valid use flag")
# if we made it here, there's no USE_EXPAND; thus just return the original sequence
return tokens
diff --git a/tests/ebuild/test_domain.py b/tests/ebuild/test_domain.py
index 28706e254..e7b93b11b 100644
--- a/tests/ebuild/test_domain.py
+++ b/tests/ebuild/test_domain.py
@@ -62,6 +62,8 @@ class TestDomain:
*/* x_y1
# unrelated is there to verify that it's unaffected by the USE_EXPAND
*/* unrelated X: -y1 y2
+ # multiple USE_EXPANDs
+ */* unrelated X: -y1 y2 Z: -z3 z4
"""
)
)
@@ -78,10 +80,31 @@ class TestDomain:
),
),
),
+ (
+ packages.AlwaysTrue,
+ (
+ ("x_y1", "z_z3"),
+ (
+ "unrelated",
+ "x_y2",
+ "z_z4",
+ ),
+ ),
+ ),
) == self.mk_domain().pkg_use
- def test_use_flag_parsing_enforcement(self):
+ def test_use_flag_parsing_enforcement(self, caplog):
(self.pusedir / "a").write_text("*/* X:")
- # TODO: need to catch the warning here, but I'm not sure how.
- # Meanwhile, ensure that the failed token is ignored.
assert ((packages.AlwaysTrue, ((), ())),) == self.mk_domain().pkg_use
+ assert caplog.text == "" # no problems with nothing after USE_EXPAND:
+ caplog.clear()
+
+ (self.pusedir / "a").write_text("*/* y $x")
+ assert () == self.mk_domain().pkg_use
+ assert "token $x is not a valid use flag" in caplog.text
+ caplog.clear()
+
+ (self.pusedir / "a").write_text("*/* y X: $z")
+ assert () == self.mk_domain().pkg_use
+ assert "token x_$z is not a valid use flag" in caplog.text
+ caplog.clear()
next reply other threads:[~2023-01-02 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-02 20:03 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-12-28 5:27 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/ebuild/, src/pkgcore/ebuild/ Arthur Zamarin
2023-10-23 17:35 Arthur Zamarin
2023-08-29 17:37 Arthur Zamarin
2023-02-02 19:58 Arthur Zamarin
2023-01-17 20:50 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
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=1672689427.e174fa3c960fef3ed6225fa9a43e14e0e11332b0.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