mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Check for default core dir in run-time (solves issue with tests)
This commit is contained in:
@ -276,6 +276,8 @@ class ProjectConfigBase(object):
|
|||||||
|
|
||||||
if value == MISSING:
|
if value == MISSING:
|
||||||
value = default if default != MISSING else option_meta.default
|
value = default if default != MISSING else option_meta.default
|
||||||
|
if callable(value):
|
||||||
|
value = value()
|
||||||
if value == MISSING:
|
if value == MISSING:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class ConfigOption(object): # pylint: disable=too-many-instance-attributes
|
|||||||
type="string",
|
type="string",
|
||||||
multiple=self.multiple,
|
multiple=self.multiple,
|
||||||
sysenvvar=self.sysenvvar,
|
sysenvvar=self.sysenvvar,
|
||||||
default=self.default,
|
default=self.default() if callable(self.default) else self.default,
|
||||||
)
|
)
|
||||||
if isinstance(self.type, click.ParamType):
|
if isinstance(self.type, click.ParamType):
|
||||||
result["type"] = self.type.name
|
result["type"] = self.type.name
|
||||||
@ -168,7 +168,7 @@ ProjectOptions = OrderedDict(
|
|||||||
),
|
),
|
||||||
oldnames=["home_dir"],
|
oldnames=["home_dir"],
|
||||||
sysenvvar="PLATFORMIO_CORE_DIR",
|
sysenvvar="PLATFORMIO_CORE_DIR",
|
||||||
default=get_default_core_dir(),
|
default=get_default_core_dir,
|
||||||
validate=validate_dir,
|
validate=validate_dir,
|
||||||
),
|
),
|
||||||
ConfigPlatformioOption(
|
ConfigPlatformioOption(
|
||||||
|
@ -254,9 +254,15 @@ def test_sysenv_options(config):
|
|||||||
os.environ["PLATFORMIO_HOME_DIR"] = custom_core_dir
|
os.environ["PLATFORMIO_HOME_DIR"] = custom_core_dir
|
||||||
os.environ["PLATFORMIO_SRC_DIR"] = custom_src_dir
|
os.environ["PLATFORMIO_SRC_DIR"] = custom_src_dir
|
||||||
os.environ["PLATFORMIO_BUILD_DIR"] = custom_build_dir
|
os.environ["PLATFORMIO_BUILD_DIR"] = custom_build_dir
|
||||||
assert config.get("platformio", "core_dir") == os.path.realpath(custom_core_dir)
|
assert os.path.realpath(config.get("platformio", "core_dir")) == os.path.realpath(
|
||||||
assert config.get("platformio", "src_dir") == os.path.realpath(custom_src_dir)
|
custom_core_dir
|
||||||
assert config.get("platformio", "build_dir") == os.path.realpath(custom_build_dir)
|
)
|
||||||
|
assert os.path.realpath(config.get("platformio", "src_dir")) == os.path.realpath(
|
||||||
|
custom_src_dir
|
||||||
|
)
|
||||||
|
assert os.path.realpath(config.get("platformio", "build_dir")) == os.path.realpath(
|
||||||
|
custom_build_dir
|
||||||
|
)
|
||||||
|
|
||||||
# cleanup system environment variables
|
# cleanup system environment variables
|
||||||
del os.environ["PLATFORMIO_BUILD_FLAGS"]
|
del os.environ["PLATFORMIO_BUILD_FLAGS"]
|
||||||
|
Reference in New Issue
Block a user