Skip to content

Commit 8270478

Browse files
committed
resolve config include FIXME
Signed-off-by: onur-ozkan <[email protected]>
1 parent 6d52b51 commit 8270478

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: src/bootstrap/src/core/config/config.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,7 @@ impl Merge for TomlConfig {
814814
exit!(2);
815815
});
816816

817-
// FIXME: Similar to `Config::parse_inner`, allow passing a custom `get_toml` from the caller to
818-
// improve testability since `Config::get_toml` does nothing when `cfg(test)` is enabled.
819-
let included_toml = Config::get_toml(&include_path).unwrap_or_else(|e| {
817+
let included_toml = Config::get_toml_inner(&include_path).unwrap_or_else(|e| {
820818
eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display());
821819
exit!(2);
822820
});
@@ -1424,13 +1422,15 @@ impl Config {
14241422
Self::get_toml(&builder_config_path)
14251423
}
14261424

1427-
#[cfg(test)]
1428-
pub(crate) fn get_toml(_: &Path) -> Result<TomlConfig, toml::de::Error> {
1429-
Ok(TomlConfig::default())
1425+
pub(crate) fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
1426+
#[cfg(test)]
1427+
return Ok(TomlConfig::default());
1428+
1429+
#[cfg(not(test))]
1430+
Self::get_toml_inner(file)
14301431
}
14311432

1432-
#[cfg(not(test))]
1433-
pub(crate) fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
1433+
fn get_toml_inner(file: &Path) -> Result<TomlConfig, toml::de::Error> {
14341434
let contents =
14351435
t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
14361436
// Deserialize to Value and then TomlConfig to prevent the Deserialize impl of

0 commit comments

Comments
 (0)