aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-10-14 22:21:07 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2022-10-14 22:34:13 +0300
commit6cf5a11fc6ff12af7c62e13329694f3c22a5e32d (patch)
treecb60d3fe3c1f90d04faebbe25e54b308a260bf1a /tests
parentbump stack dependencies versions (diff)
downloadpkgdev-6cf5a11fc6ff12af7c62e13329694f3c22a5e32d.tar.gz
pkgdev-6cf5a11fc6ff12af7c62e13329694f3c22a5e32d.tar.bz2
pkgdev-6cf5a11fc6ff12af7c62e13329694f3c22a5e32d.zip
manifest: better handling of path target
When passing a `.` path while inside a package directory, it passed to path restrict generator as a simple path, which resulted in broken restrict which collected all ebuilds in the repository. By using `os.path.relpath` to base of repository, we make sure the correct path is passed and the correct restricts are generated. Fixes: https://github.com/pkgcore/pkgdev/issues/85 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/test_pkgdev_manifest.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index 0c1c8c8..2800236 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -24,6 +24,38 @@ class TestPkgdevManifestParseArgs:
matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
assert matches == ['cat/pkg-0']
+ def test_repo_relative_pkg(self, repo, capsys, tool):
+ repo.create_ebuild('cat/pkg-0')
+ repo.create_ebuild('cat/newpkg-0')
+ with chdir(pjoin(repo.location, 'cat/pkg')):
+ options, _ = tool.parse_args(['manifest', '.'])
+ matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+ assert matches == ['cat/pkg-0']
+
+ def test_repo_relative_category(self, repo, capsys, tool):
+ repo.create_ebuild('cat/pkg-0')
+ repo.create_ebuild('cat/newpkg-0')
+
+ with chdir(pjoin(repo.location, 'cat')):
+ options, _ = tool.parse_args(['manifest', 'pkg'])
+ matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+ assert matches == ['cat/pkg-0']
+
+ with chdir(pjoin(repo.location, 'cat')):
+ options, _ = tool.parse_args(['manifest', '.'])
+ matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
+ assert set(matches) == {'cat/pkg-0', 'cat/newpkg-0'}
+
+ def test_repo_relative_outside(self, tmp_path, repo, capsys, tool):
+ repo.create_ebuild('cat/pkg-0')
+ (ebuild := tmp_path / 'pkg.ebuild').touch()
+ with pytest.raises(SystemExit) as excinfo:
+ with chdir(repo.location):
+ tool.parse_args(['manifest', str(ebuild)])
+ assert excinfo.value.code == 2
+ out, err = capsys.readouterr()
+ assert err.strip() == f"pkgdev manifest: error: {repo.repo_id!r} repo doesn't contain: {str(ebuild)!r}"
+
def test_dir_target(self, repo, capsys, tool):
repo.create_ebuild('cat/pkg-0')
with chdir(repo.location):