test_build_system: fix incomplete env returned by get_idf_build_env

Previously get_idf_build_env didn't include the default environment
(os.environ) in its output, so the environment only contained the
variables returned by "idf_tools.py export".
If PATH already contains all the right paths, "idf_tools.py export"
doesn't return the PATH variable.
Therefore the environment returned by get_idf_build_env was usually
incomplete. Fix by combining the output of "idf_tools.py export" with
os.environ.
This commit is contained in:
Ivan Grokhotkov
2022-11-01 20:03:19 +01:00
parent 5d2f900bef
commit 03c542ecf7

View File

@@ -43,8 +43,11 @@ def get_idf_build_env(idf_path: str) -> EnvDict:
'--format=key-value'
]
keys_values = subprocess.check_output(cmd, stderr=subprocess.PIPE).decode()
env_vars = {key: os.path.expandvars(value) for key, value in
[line.split('=') for line in keys_values.splitlines()]}
idf_tool_py_env = {key: os.path.expandvars(value) for key, value in
[line.split('=') for line in keys_values.splitlines()]}
env_vars = {} # type: EnvDict
env_vars.update(os.environ)
env_vars.update(idf_tool_py_env)
# not set by idf_tools.py, normally set by export.sh
env_vars['IDF_PATH'] = idf_path