|
7 | 7 | from unittest.mock import patch |
8 | 8 |
|
9 | 9 | import pytest |
10 | | -from pkgdev.mangle import copyright_regex |
| 10 | +from pkgdev.mangle import copyright_regex, keywords_regex |
11 | 11 | from pkgdev.scripts import run |
12 | 12 | from snakeoil.contexts import chdir, os_environ |
13 | 13 | from snakeoil.osutils import pjoin |
@@ -809,6 +809,27 @@ def commit(args): |
809 | 809 | assert mo.group('begin') == years[:4] + '-' |
810 | 810 | assert mo.group('holder') == 'Gentoo Authors' |
811 | 811 |
|
| 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 | + |
812 | 833 | def test_scan(self, capsys, repo, make_git_repo): |
813 | 834 | git_repo = make_git_repo(repo.location) |
814 | 835 | repo.create_ebuild('cat/pkg-0') |
|
0 commit comments