From ced93fee7b40ae87c8af2c4b5c64be1ea67add28 Mon Sep 17 00:00:00 2001 From: Newbyte Date: Thu, 14 Mar 2024 22:50:26 +0100 Subject: [PATCH] pmb.parse.kconfig: Raise NonBugError on invalid kernel config (MR 2279) The intent of 9a74848f191db88b964b293971f589042aba9938 was to not print a stacktrace when this happened. However, I still opted to raise an exception, so you still get a stacktrace, just with a more helpful message. There's no need to give the user a big stacktrace here, so raise a NonBugError instead of a RuntimeError. --- pmb/parse/kconfig.py | 13 +++++++------ test/test_parse_kconfig.py | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pmb/parse/kconfig.py b/pmb/parse/kconfig.py index 9562dd71..872098b9 100644 --- a/pmb/parse/kconfig.py +++ b/pmb/parse/kconfig.py @@ -9,6 +9,7 @@ import pmb.build import pmb.config import pmb.parse import pmb.helpers.pmaports +from pmb.helpers.exceptions import NonBugError def get_all_component_names(): @@ -271,12 +272,12 @@ def check(args, pkgname, components_list=[], details=False, must_exist=True): config_name_split = config_name.split(".") if len(config_name_split) != 2: - raise RuntimeError(f"{config_name} is not a valid kernel config " - "name. Ensure that the _config property in your " - "kernel APKBUILD has a . before the " - "architecture name, e.g. .aarch64 or .armv7, " - "and that there is no excess punctuation " - "elsewhere in the name.") + raise NonBugError(f"ERROR: {config_name} is not a valid kernel config " + "name. Ensure that the _config property in your " + "kernel APKBUILD has a . before the " + "architecture name, e.g. .aarch64 or .armv7, " + "and that there is no excess punctuation " + "elsewhere in the name.") config_arch = config_name_split[1] ret &= check_config(config_path, config_arch, pkgver, components_list, diff --git a/test/test_parse_kconfig.py b/test/test_parse_kconfig.py index 8c6d311c..2c148190 100644 --- a/test/test_parse_kconfig.py +++ b/test/test_parse_kconfig.py @@ -7,6 +7,7 @@ import os import pmb_test # noqa import pmb.parse.kconfig +from pmb.helpers.exceptions import NonBugError test_options_checked_count = None @@ -345,7 +346,7 @@ def test_check(args, monkeypatch, tmpdir): handle.write('CONFIG_BOOL=m\n') must_exist = True pkgname = "linux-nokia-n900" - with pytest.raises(RuntimeError) as e: + with pytest.raises(NonBugError) as e: func(args, pkgname, components_list, details, must_exist) assert "is not a valid kernel config" in str(e.value) os.unlink(path_kconfig)