Skip to content

Commit

Permalink
Adding UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Nov 11, 2024
1 parent f016716 commit 9481bdd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/fprime/fbuild/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {}
Expand Down
6 changes: 6 additions & 0 deletions test/fprime/fbuild/settings-data/settings-environment.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[fprime]
framework_path: ../..

[environment]
MY_VARIABLE: my value
MY_VARIABLE_2: ${TEST_SETTING_1}:$TEST_SETTING_2
27 changes: 25 additions & 2 deletions test/fprime/fbuild/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Tests the F prime settings module.
@author joshuaa
"""

import os
from pathlib import Path

from fprime.fbuild.settings import IniSettings
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9481bdd

Please sign in to comment.