diff --git a/src/fprime/fbuild/settings.py b/src/fprime/fbuild/settings.py index 7a6e56ca..6bed892a 100644 --- a/src/fprime/fbuild/settings.py +++ b/src/fprime/fbuild/settings.py @@ -202,7 +202,7 @@ def load(settings_file: Path, platform: str = "native", is_ut: bool = False): # Setup a config parser, or none if the settings file does not exist confparse = None if settings_file.exists(): - confparse = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation) + confparse = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation()) confparse.read(settings_file) else: print(f"[WARNING] {settings_file} does not exist", file=sys.stderr) @@ -266,7 +266,7 @@ def load_environment(env_file): :param env_file: load environment from this file :return: environment dictionary """ - parser = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation) + parser = configparser.ConfigParser(interpolation=EnvironmentVariableInterpolation()) parser.optionxform = str parser.read(env_file) env_dict = {} diff --git a/test/fprime/fbuild/settings-data/settings-environment.ini b/test/fprime/fbuild/settings-data/settings-environment.ini new file mode 100644 index 00000000..8d698691 --- /dev/null +++ b/test/fprime/fbuild/settings-data/settings-environment.ini @@ -0,0 +1,6 @@ +[fprime] +framework_path: ../.. + +[environment] +MY_VARIABLE: my value +MY_VARIABLE_2: ${TEST_SETTING_1}:$TEST_SETTING_2 diff --git a/test/fprime/fbuild/test_settings.py b/test/fprime/fbuild/test_settings.py index 8de2bef0..7a7bdd42 100644 --- a/test/fprime/fbuild/test_settings.py +++ b/test/fprime/fbuild/test_settings.py @@ -4,7 +4,7 @@ Tests the F prime settings module. @author joshuaa """ - +import os from pathlib import Path from fprime.fbuild.settings import IniSettings @@ -126,8 +126,31 @@ def test_settings(): "default_cmake_options": "OPTION1=ABC\nOPTION2=123\nOPTION3=Something", }, }, + { + "file": "settings-environment.ini", + "expected": { + "settings_file": full_path("settings-data/settings-environment.ini"), + "default_toolchain": "native", + "default_ut_toolchain": "native", + "framework_path": full_path(".."), + "install_destination": full_path("settings-data/build-artifacts"), + "library_locations": [], + "environment_file": full_path("settings-data/settings-environment.ini"), + "environment": { + "MY_VARIABLE": "my value", + "MY_VARIABLE_2": "abc:123" + }, + "component_cookiecutter": "default", + "deployment_cookiecutter": "default", + "project_root": full_path(".."), + "config_directory": full_path("..") / "config", + "default_cmake_options": "", + }, + }, ] - + # Prep for substitution + os.environ["TEST_SETTING_1"] = "abc" + os.environ["TEST_SETTING_2"] = "123" for case in test_cases: fp = full_path("settings-data/" + case["file"]) results = IniSettings.load(fp)