aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-03-23 21:18:52 +0200
committerArthur Zamarin <arthurzam@gmail.com>2022-03-25 12:09:49 +0300
commit00813f7469c31341732680f8d32ffa539e8ff493 (patch)
tree7a8360c5af220955f1bc4c97758120c5e34bf6ed /tests
parentAdd keywords reordering mangler (diff)
downloadpkgdev-00813f7469c31341732680f8d32ffa539e8ff493.tar.gz
pkgdev-00813f7469c31341732680f8d32ffa539e8ff493.tar.bz2
pkgdev-00813f7469c31341732680f8d32ffa539e8ff493.zip
Add tests for keywords mangler
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/test_pkgdev_commit.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py
index f409360..ccebb2a 100644
--- a/tests/scripts/test_pkgdev_commit.py
+++ b/tests/scripts/test_pkgdev_commit.py
@@ -7,7 +7,7 @@ from io import StringIO
from unittest.mock import patch
import pytest
-from pkgdev.mangle import copyright_regex
+from pkgdev.mangle import copyright_regex, keywords_regex
from pkgdev.scripts import run
from snakeoil.contexts import chdir, os_environ
from snakeoil.osutils import pjoin
@@ -809,6 +809,27 @@ class TestPkgdevCommit:
assert mo.group('begin') == years[:4] + '-'
assert mo.group('holder') == 'Gentoo Authors'
+ for original, expected in (
+ ('"arm64 amd64 x86"', 'amd64 arm64 x86'),
+ ('"arm64 amd64 ~x86"', 'amd64 arm64 ~x86'),
+ ('"arm64 ~x86 amd64"', 'amd64 arm64 ~x86'),
+ ('"arm64 ~x86 ~amd64"', '~amd64 arm64 ~x86'),
+ ('arm64 ~x86 ~amd64', '~amd64 arm64 ~x86'),
+ ):
+ # munge the keywords
+ with open(ebuild_path, 'r+') as f:
+ lines = f.read().splitlines()
+ lines[-1] = f'KEYWORDS={original}'
+ f.seek(0)
+ f.truncate()
+ f.write('\n'.join(lines) + '\n')
+ commit(['-n', '-u', '-m', 'mangling'])
+ # verify the keywords were updated
+ with open(ebuild_path) as f:
+ lines = f.read().splitlines()
+ mo = keywords_regex.match(lines[-1])
+ assert mo.group('keywords') == expected
+
def test_scan(self, capsys, repo, make_git_repo):
git_repo = make_git_repo(repo.location)
repo.create_ebuild('cat/pkg-0')