Skip to content

Commit

Permalink
BadDependency: catch := slot operator in PDEPEND
Browse files Browse the repository at this point in the history
Resolves: #693
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
  • Loading branch information
arthurzam committed Jul 19, 2024
1 parent dacab55 commit 04c8872
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pkgcheck/checks/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,15 @@ def feed(self, pkg):
if all(map(self.deprecated, pkgs)):
deprecated[attr].add(atom)

if in_or_restriction and atom.slot_operator == "=":
yield BadDependency(
attr, atom, "= slot operator used inside || block", pkg=pkg
)
if atom.slot_operator == "=":
if in_or_restriction:
yield BadDependency(
attr, atom, "= slot operator used inside || block", pkg=pkg
)
elif attr == "pdepend" and not atom.blocks:
# prohibited by PMS at the "Slot dependencies" section
msg = "':=' operator is invalid in"
yield BadDependency(attr, atom, msg, pkg=pkg)

if pkg.eapi.options.has_use_dep_defaults and atom.use is not None:
missing_use_deps = self._check_use_deps(attr, atom)
Expand Down
7 changes: 7 additions & 0 deletions tests/checks/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,13 @@ def test_depset(self, attr):
assert "= slot operator used in blocker" in str(r)
assert f'{attr.upper()}="!dev-libs/foo:="' in str(r)

if attr == "PDEPEND":
# check for := in PDEPEND
r = self.assertReport(chk, mk_pkg(eapi="5", depset="dev-libs/foo:="))
assert isinstance(r, metadata.BadDependency)
assert "':=' operator" in str(r)
assert f'{attr.upper()}="dev-libs/foo:="' in str(r)

# check for missing package revisions
self.assertNoReport(chk, mk_pkg("=dev-libs/foo-1-r0"))
r = self.assertReport(chk, mk_pkg(eapi="6", depset="=dev-libs/foo-1"))
Expand Down

0 comments on commit 04c8872

Please sign in to comment.