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
if len(eggv) == 0:
raise ValueError('egg %s not found' % eggname)
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')
elif recipe == 'slapos.recipe.build:gitclone':
......
......@@ -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/
""")
# 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
case1("""\
[libreoffice-bin]
......@@ -422,6 +435,11 @@ def test_bom_software(tmpdir, build, bomok):
with open(f, 'w') as _:
_.write(data)
if isinstance(bomok, Exception):
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
......
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