pmb.parse.kconfig: Raise NonBugError on invalid kernel config (MR 2279)
The intent of 9a74848f19
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.
This commit is contained in:
parent
9723191fe5
commit
ced93fee7b
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue