Skip to content

Commit

Permalink
Add tests for keywords mangler
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
  • Loading branch information
arthurzam committed Mar 23, 2022
1 parent f06d52c commit cb073ad
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/scripts/test_pkgdev_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down Expand Up @@ -808,6 +808,26 @@ def commit(args):
assert mo.group('end') == str(datetime.today().year)
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'),
):
# 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')
Expand Down

0 comments on commit cb073ad

Please sign in to comment.