mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Run config option validation even in raw mode
This commit is contained in:
@ -279,6 +279,9 @@ class ProjectConfigBase(object):
|
|||||||
if value == MISSING:
|
if value == MISSING:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if option_meta.validate:
|
||||||
|
value = option_meta.validate(value)
|
||||||
|
|
||||||
return self._expand_interpolations(value)
|
return self._expand_interpolations(value)
|
||||||
|
|
||||||
def _expand_interpolations(self, value):
|
def _expand_interpolations(self, value):
|
||||||
@ -315,11 +318,8 @@ class ProjectConfigBase(object):
|
|||||||
if not option_meta:
|
if not option_meta:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
if option_meta.validate:
|
|
||||||
value = option_meta.validate(value)
|
|
||||||
if option_meta.multiple:
|
if option_meta.multiple:
|
||||||
value = self.parse_multi_values(value or [])
|
value = self.parse_multi_values(value or [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.cast_to(value, option_meta.type)
|
return self.cast_to(value, option_meta.type)
|
||||||
except click.BadParameter as e:
|
except click.BadParameter as e:
|
||||||
|
@ -107,6 +107,9 @@ def expand_dir_templates(path):
|
|||||||
def validate_dir(path):
|
def validate_dir(path):
|
||||||
if not path:
|
if not path:
|
||||||
return path
|
return path
|
||||||
|
# if not all values expanded, ignore validation
|
||||||
|
if "${" in path and "}" in path:
|
||||||
|
return path
|
||||||
if path.startswith("~"):
|
if path.startswith("~"):
|
||||||
path = fs.expanduser(path)
|
path = fs.expanduser(path)
|
||||||
if "$" in path:
|
if "$" in path:
|
||||||
|
@ -466,14 +466,7 @@ def test_dump(tmpdir_factory):
|
|||||||
(
|
(
|
||||||
"platformio",
|
"platformio",
|
||||||
[
|
[
|
||||||
(
|
("build_dir", "~/tmp/pio-$PROJECT_HASH"),
|
||||||
"build_dir",
|
|
||||||
"%s-%s"
|
|
||||||
% (
|
|
||||||
os.path.realpath(fs.expanduser("~/tmp/pio")),
|
|
||||||
calculate_path_hash(os.getcwd()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("extra_configs", ["extra_envs.ini", "extra_debug.ini"]),
|
("extra_configs", ["extra_envs.ini", "extra_debug.ini"]),
|
||||||
("default_envs", ["base", "extra_2"]),
|
("default_envs", ["base", "extra_2"]),
|
||||||
],
|
],
|
||||||
@ -536,6 +529,9 @@ def test_win_core_root_dir(tmpdir_factory):
|
|||||||
# Default config
|
# Default config
|
||||||
config = ProjectConfig()
|
config = ProjectConfig()
|
||||||
assert config.get("platformio", "core_dir") == win_core_root_dir
|
assert config.get("platformio", "core_dir") == win_core_root_dir
|
||||||
|
assert config.get("platformio", "packages_dir") == os.path.join(
|
||||||
|
win_core_root_dir, "packages"
|
||||||
|
)
|
||||||
|
|
||||||
# Override in config
|
# Override in config
|
||||||
tmpdir = tmpdir_factory.mktemp("project")
|
tmpdir = tmpdir_factory.mktemp("project")
|
||||||
|
Reference in New Issue
Block a user