Add %version_no_operators macro and tests.

This commit is contained in:
Gordon Messmer 2021-06-20 15:12:53 -07:00
parent 370b825e45
commit 9ec9c1fb5b
2 changed files with 21 additions and 0 deletions

View File

@ -221,3 +221,14 @@
end
end
}}
%version_no_operators() %{lua:
local ver = rpm.expand('%1')
\
if ver == '%1' then
ver = rpm.expand('%version')
end
ver = ver:gsub('[~^]+', '')
\
print(ver)
}

View File

@ -73,6 +73,16 @@ def test_pydist_name(argument, result):
assert rpm_eval(f'%py_dist_name {argument}') == [result]
@pytest.mark.parametrize('argument, result', [
('7.5.0~~dev1', '7.5.0dev1'),
('7.5.0~b4', '7.5.0b4'),
('7.5.0', '7.5.0'),
('7.5.0^post1', '7.5.0post1'),
])
def test_version_no_operators(argument, result):
assert rpm_eval(f'%version_no_operators {argument}') == [result]
def test_py2_dist():
assert rpm_eval(f'%py2_dist Aha[Boom] a') == ['python2dist(aha[boom]) python2dist(a)']