conf: warn on conflicting settings (all-features + hidden features)
This commit is contained in:
parent
97fd500e75
commit
d1ae15ad6e
1 changed files with 39 additions and 23 deletions
|
@ -735,36 +735,52 @@ class TomlConf:
|
|||
|
||||
jsonschema.validate(toml, TOML_SCHEMA)
|
||||
|
||||
if tests := toml.get("tests"):
|
||||
if run := tests.get("run"):
|
||||
if "all" in run:
|
||||
if len(run) != 1:
|
||||
raise ConfError(f"Invalid set of tests to run: {run!r}")
|
||||
if "none" in run:
|
||||
if len(run) != 1:
|
||||
raise ConfError(f"Invalid set of tests to run: {run!r}")
|
||||
conf = TomlConf(toml)
|
||||
|
||||
# the "default" feature is always implicitly defined
|
||||
if "default" not in features:
|
||||
features.add("default")
|
||||
|
||||
if features_list := toml.get("features"):
|
||||
if enable_list := features_list.get("enable"):
|
||||
for enabled in enable_list:
|
||||
if enabled not in features:
|
||||
raise ConfError(f'Unrecognized "enabled" feature: {enabled!r}')
|
||||
if hide_list := features_list.get("hide"):
|
||||
for hidden in hide_list:
|
||||
if hidden not in features:
|
||||
raise ConfError(f'Unrecognized "hidden" feature: {hidden!r}')
|
||||
# validate the "tests.run" setting:
|
||||
# both "all" and "none" cannot be combimed with other values
|
||||
if tests_run := conf.tests_run:
|
||||
if "all" in tests_run:
|
||||
if len(tests_run) != 1:
|
||||
raise ConfError(f"Invalid set of tests to run: {tests_run!r}")
|
||||
if "none" in tests_run:
|
||||
if len(tests_run) != 1:
|
||||
raise ConfError(f"Invalid set of tests to run: {tests_run!r}")
|
||||
|
||||
if requires_table := toml.get("requires"):
|
||||
if features_list := requires_table.get("features"):
|
||||
for enabled in features_list:
|
||||
if enabled not in features:
|
||||
raise ConfError(f'Unrecognized "Requires" for feature: {enabled!r}')
|
||||
# validate the "features.enable" setting:
|
||||
# list elements must be valid feature names
|
||||
if enable_list := conf.features_enable:
|
||||
for enabled in enable_list:
|
||||
if enabled not in features:
|
||||
raise ConfError(f'Unrecognized "enabled" feature: {enabled!r}')
|
||||
|
||||
return TomlConf(toml)
|
||||
# validate the "features.hide" setting:
|
||||
# list elements must be valid feature names
|
||||
if hide_list := conf.features_hide:
|
||||
for hidden in hide_list:
|
||||
if hidden not in features:
|
||||
raise ConfError(f'Unrecognized "hidden" feature: {hidden!r}')
|
||||
|
||||
# validate the "requires.features" setting
|
||||
# dictionary keys must be valid feature names
|
||||
if feature_requires := conf.requires_features:
|
||||
for feature in feature_requires.keys():
|
||||
if feature not in features:
|
||||
raise ConfError(f'Unrecognized "Requires" for feature: {enabled!r}')
|
||||
|
||||
# warn when conflicting settings are used
|
||||
if (conf.features_enable_all is True) and (conf.features_hide is not None and len(conf.features_hide) > 0):
|
||||
log.warn(
|
||||
"Conflicting settings for features: "
|
||||
"All features are enabled for the build but some feature subpackages are hidden. "
|
||||
"This is likely an error."
|
||||
)
|
||||
|
||||
return conf
|
||||
|
||||
@staticmethod
|
||||
def from_conf(conf: IniConf) -> "TomlConf":
|
||||
|
|
Loading…
Reference in a new issue