[store_yaml] Gate YAML discovery on component presence, fail on unreadable files, warn on unresolved includes

This commit is contained in:
J. Nick Koston
2026-07-03 19:17:04 -05:00
parent d6019ca2c0
commit f3ac60b45c
6 changed files with 111 additions and 19 deletions
+22
View File
@@ -1084,6 +1084,18 @@ def test_force_load_include_files_unresolved_log_level(
assert matching == [expect_level]
def test_force_load_include_files_returns_unresolved_paths(
patch_include_file: None,
) -> None:
"""Includes with substitution-templated paths are reported back to the
caller; resolvable ones are not."""
templated = _StubInclude("${var}.yaml", unresolved=True)
plain = _StubInclude("ok.yaml")
unresolved = force_load_include_files({"a": templated, "b": plain})
assert unresolved == [str(templated.file)]
assert plain.load_calls == 1
def test_force_load_include_files_warns_on_load_failure(
patch_include_file: None,
caplog: pytest.LogCaptureFixture,
@@ -1169,6 +1181,16 @@ def test_discover_user_yaml_files_swallows_parse_errors(tmp_path: Path) -> None:
assert isinstance(discovered, DiscoveredYamlFiles)
def test_discover_user_yaml_files_reports_unresolved_includes(
tmp_path: Path,
) -> None:
"""A substitution-templated `!include` path is surfaced in `.unresolved`."""
entry = _write_entry_including(tmp_path, "${board}.yaml")
discovered = discover_user_yaml_files(entry)
assert len(discovered.unresolved) == 1
assert "${board}.yaml" in discovered.unresolved[0]
def test_discover_user_yaml_files_deduplicates(tmp_path: Path) -> None:
"""The same file referenced twice appears once in `.files`."""
_write(tmp_path, "wifi.yaml", "ssid: a\n")