Skip to content

Commit 00813f7

Browse files
committed
Add tests for keywords mangler
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 4f842ee commit 00813f7

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

tests/scripts/test_pkgdev_commit.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from unittest.mock import patch
88

99
import pytest
10-
from pkgdev.mangle import copyright_regex
10+
from pkgdev.mangle import copyright_regex, keywords_regex
1111
from pkgdev.scripts import run
1212
from snakeoil.contexts import chdir, os_environ
1313
from snakeoil.osutils import pjoin
@@ -809,6 +809,27 @@ def commit(args):
809809
assert mo.group('begin') == years[:4] + '-'
810810
assert mo.group('holder') == 'Gentoo Authors'
811811

812+
for original, expected in (
813+
('"arm64 amd64 x86"', 'amd64 arm64 x86'),
814+
('"arm64 amd64 ~x86"', 'amd64 arm64 ~x86'),
815+
('"arm64 ~x86 amd64"', 'amd64 arm64 ~x86'),
816+
('"arm64 ~x86 ~amd64"', '~amd64 arm64 ~x86'),
817+
('arm64 ~x86 ~amd64', '~amd64 arm64 ~x86'),
818+
):
819+
# munge the keywords
820+
with open(ebuild_path, 'r+') as f:
821+
lines = f.read().splitlines()
822+
lines[-1] = f'KEYWORDS={original}'
823+
f.seek(0)
824+
f.truncate()
825+
f.write('\n'.join(lines) + '\n')
826+
commit(['-n', '-u', '-m', 'mangling'])
827+
# verify the keywords were updated
828+
with open(ebuild_path) as f:
829+
lines = f.read().splitlines()
830+
mo = keywords_regex.match(lines[-1])
831+
assert mo.group('keywords') == expected
832+
812833
def test_scan(self, capsys, repo, make_git_repo):
813834
git_repo = make_git_repo(repo.location)
814835
repo.create_ebuild('cat/pkg-0')

0 commit comments

Comments
 (0)