Commit 6bcdd408 authored by Kirill Smelkov's avatar Kirill Smelkov

Fix reporting of multiple detected eggs

It was failing with

                        if len(eggv) > 1:
    >                       raise ValueError('egg %s is present multiple times: %s' % (egg, eggv))
    E                       NameError: name 'egg' is not defined

I hit this for real when trying to build multiple SRs on the same Theia.
parent 4b90d0a4
...@@ -212,7 +212,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -212,7 +212,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
if len(eggv) == 0: if len(eggv) == 0:
raise ValueError('egg %s not found' % eggname) raise ValueError('egg %s not found' % eggname)
if len(eggv) > 1: if len(eggv) > 1:
raise ValueError('egg %s is present multiple times: %s' % (egg, eggv)) eggv.sort()
raise ValueError('egg %s is present multiple times: %s' % (eggname, eggv))
addbom(eggv[0], 'egg') addbom(eggv[0], 'egg')
elif recipe == 'slapos.recipe.build:gitclone': elif recipe == 'slapos.recipe.build:gitclone':
......
...@@ -389,6 +389,19 @@ bbb 3.4 https://pypi.org/project/bbb/3.4/ ...@@ -389,6 +389,19 @@ bbb 3.4 https://pypi.org/project/bbb/3.4/
ccc 5.6.7 https://pypi.org/project/ccc/5.6.7/ ccc 5.6.7 https://pypi.org/project/ccc/5.6.7/
""") """)
# multiple eggs are rejected
# TODO try to improve zc.recipe.egg to emit information into .installed.cfg instead of us scanning the filesystem
case1("""
[ccc]
recipe = zc.recipe.egg
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
eggs = setuptools
-- /ROOT/eggs/setuptools-44.1.1-py3.7.egg --
-- /ROOT/eggs/setuptools-44.1.1-py3.9.egg --
""",
ValueError("egg setuptools is present multiple times: ['setuptools-44.1.1-py3.7.egg', 'setuptools-44.1.1-py3.9.egg']"))
# libreoffice # libreoffice
case1("""\ case1("""\
[libreoffice-bin] [libreoffice-bin]
...@@ -422,8 +435,13 @@ def test_bom_software(tmpdir, build, bomok): ...@@ -422,8 +435,13 @@ def test_bom_software(tmpdir, build, bomok):
with open(f, 'w') as _: with open(f, 'w') as _:
_.write(data) _.write(data)
bom = nxdbom.bom_software(tmpdir) if isinstance(bomok, Exception):
assert nxdbom.fmt_bom(bom) == bomok with pytest.raises(type(bomok)) as e:
nxdbom.bom_software(tmpdir)
assert str(e.value) == str(bomok)
else:
bom = nxdbom.bom_software(tmpdir)
assert nxdbom.fmt_bom(bom) == bomok
# loading non-existing .installed.cfg -> error # loading non-existing .installed.cfg -> error
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment