Fixed a bug when the system environment variable does not override a project configuration option // Resolve #4125

This commit is contained in:
Ivan Kravets
2021-12-02 13:13:07 +02:00
parent 414a194c9d
commit e40b251c06
3 changed files with 13 additions and 4 deletions

View File

@ -16,6 +16,7 @@ PlatformIO Core 5
- Upgraded build engine to the SCons 4.3 (`release notes <https://github.com/SCons/scons/blob/rel_4.3.0/CHANGES.txt>`__)
- Fixed an issue with the CLion project generator when a macro contains a space (`issue #4102 <https://github.com/platformio/platformio-core/issues/4102>`_)
- Fixed an issue with the NetBeans project generator when the path to PlatformIO contains a space (`issue #4096 <https://github.com/platformio/platformio-core/issues/4096>`_)
- Fixed a bug when the system environment variable does not override a project configuration option (`issue #4125 <https://github.com/platformio/platformio-core/issues/4125>`_)
5.2.3 (2021-11-05)
~~~~~~~~~~~~~~~~~~

View File

@ -271,7 +271,7 @@ class ProjectConfigBase(object):
if value == MISSING:
value = ""
value += ("\n" if value else "") + envvar_value
elif envvar_value and value == MISSING:
elif envvar_value:
value = envvar_value
if value == MISSING:

View File

@ -226,7 +226,7 @@ def test_sysenv_options(config):
"-DSYSENVDEPS1 -DSYSENVDEPS2",
]
assert config.get("env:base", "upload_port") == "/dev/sysenv/port"
assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port"
assert config.get("env:extra_2", "upload_port") == "/dev/sysenv/port"
assert config.get("env:base", "build_unflags") == ["-DREMOVE_MACRO"]
# env var as option
@ -244,10 +244,16 @@ def test_sysenv_options(config):
"upload_port",
]
# sysenv
custom_core_dir = os.path.join(os.getcwd(), "custom")
# sysenv dirs
custom_core_dir = os.path.join(os.getcwd(), "custom-core")
custom_src_dir = os.path.join(os.getcwd(), "custom-src")
custom_build_dir = os.path.join(os.getcwd(), "custom-build")
os.environ["PLATFORMIO_HOME_DIR"] = custom_core_dir
os.environ["PLATFORMIO_SRC_DIR"] = custom_src_dir
os.environ["PLATFORMIO_BUILD_DIR"] = custom_build_dir
assert config.get("platformio", "core_dir") == os.path.realpath(custom_core_dir)
assert config.get("platformio", "src_dir") == os.path.realpath(custom_src_dir)
assert config.get("platformio", "build_dir") == os.path.realpath(custom_build_dir)
# cleanup system environment variables
del os.environ["PLATFORMIO_BUILD_FLAGS"]
@ -255,6 +261,8 @@ def test_sysenv_options(config):
del os.environ["PLATFORMIO_UPLOAD_PORT"]
del os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"]
del os.environ["PLATFORMIO_HOME_DIR"]
del os.environ["PLATFORMIO_SRC_DIR"]
del os.environ["PLATFORMIO_BUILD_DIR"]
def test_getraw_value(config):