Skip to content

Commit

Permalink
osbuild: also print what export is availalble when one is not found
Browse files Browse the repository at this point in the history
The current error message when an export is not found could be
improved by printing what exports are actually availalble to make
it easier for the user to e.g. spot typos.
  • Loading branch information
mvo5 authored and bcl committed Sep 10, 2024
1 parent 09da4ff commit f3188e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion osbuild/main_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def osbuild_cli() -> int:
exports = set(args.export)
unresolved = [e for e in exports if e not in manifest]
if unresolved:
available = list(manifest.pipelines.keys())
for name in unresolved:
print(f"Export {vt.bold}{name}{vt.reset} not found!")
print(f"Export {vt.bold}{name}{vt.reset} not found in {available}")
print(f"{vt.reset}{vt.bold}{vt.red}Failed{vt.reset}")
return 1

Expand Down
24 changes: 24 additions & 0 deletions test/run/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json

import pytest

from .. import test

jsondata = json.dumps({
"version": "2",
"pipelines": [
{
"name": "noop",
},
{
"name": "noop2",
},
],
})


def test_exports_are_shown_on_missing_exports(capsys):
with pytest.raises(AssertionError):
with test.OSBuild() as osb:
osb.compile(jsondata, exports=["not-existing"])
assert "Export not-existing not found in ['noop', 'noop2']\n" in capsys.readouterr().out

0 comments on commit f3188e8

Please sign in to comment.