aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-05-04 20:08:36 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2022-05-05 20:27:49 +0300
commit9ed5db0a2c63c105feefb124d290949f54a1a86c (patch)
tree1c83187bdf43e199bb7ea2f4a4fc992723a813b0 /tests
parentAdd documentation for configuration (diff)
downloadpkgdev-9ed5db0a2c63c105feefb124d290949f54a1a86c.tar.gz
pkgdev-9ed5db0a2c63c105feefb124d290949f54a1a86c.tar.bz2
pkgdev-9ed5db0a2c63c105feefb124d290949f54a1a86c.zip
pkgdev manifest: add --if-modified
Restrict targets for manifest to only targets that have uncommitted modifications. Resolves: https://github.com/pkgcore/pkgdev/issues/65 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/test_pkgdev_manifest.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/scripts/test_pkgdev_manifest.py b/tests/scripts/test_pkgdev_manifest.py
index 1131ff7..696a2f2 100644
--- a/tests/scripts/test_pkgdev_manifest.py
+++ b/tests/scripts/test_pkgdev_manifest.py
@@ -1,4 +1,5 @@
from functools import partial
+from typing import Set
from unittest.mock import patch
import pytest
@@ -44,6 +45,55 @@ class TestPkgdevManifestParseArgs:
matches = [x.cpvstr for x in repo.itermatch(options.restriction)]
assert matches == ['cat/pkg-0']
+ def test_if_modified_target(self, repo, make_git_repo, tool):
+ def manifest_matches() -> Set[str]:
+ repo.sync()
+ with chdir(repo.location):
+ options, _ = tool.parse_args(['manifest', '--if-modified'])
+ return {x.cpvstr for x in repo.itermatch(options.restriction)}
+
+ git_repo = make_git_repo(repo.location)
+ repo.create_ebuild('cat/oldpkg-0')
+ git_repo.add_all('cat/oldpkg-0')
+
+ # New package
+ repo.create_ebuild('cat/newpkg-0')
+ assert manifest_matches() == {'cat/newpkg-0'}
+ git_repo.add_all('cat/newpkg-0')
+
+ # Untracked file
+ ebuild_path = repo.create_ebuild('cat/newpkg-1')
+ assert manifest_matches() == {'cat/newpkg-1'}
+
+ # Staged file
+ git_repo.add(ebuild_path, commit=False)
+ assert manifest_matches() == {'cat/newpkg-1'}
+
+ # No modified files
+ git_repo.add_all('cat/newpkg-1')
+ assert manifest_matches() == set()
+
+ # Modified file
+ ebuild_path = repo.create_ebuild('cat/newpkg-1', eapi=8)
+ assert manifest_matches() == {'cat/newpkg-1'}
+ git_repo.add_all('cat/newpkg-1: eapi 8')
+
+ # Renamed file
+ git_repo.remove(ebuild_path, commit=False)
+ ebuild_path = repo.create_ebuild('cat/newpkg-2')
+ git_repo.add(ebuild_path, commit=False)
+ assert manifest_matches() == {'cat/newpkg-2'}
+ git_repo.add_all('cat/newpkg-2: rename')
+
+ # Deleted file
+ git_repo.remove(ebuild_path, commit=False)
+ assert manifest_matches() == set()
+
+ # Deleted package
+ ebuild_path = repo.create_ebuild('cat/newpkg-0')
+ git_repo.remove(ebuild_path, commit=False)
+ assert manifest_matches() == set()
+
def test_non_repo_dir_target(self, tmp_path, repo, capsys, tool):
with pytest.raises(SystemExit) as excinfo, \
chdir(repo.location):