mirror of
https://github.com/esphome/esphome.git
synced 2026-10-03 17:55:57 +00:00
[core] Log which source change triggered a rebuild (#18552)
This commit is contained in:
@@ -929,11 +929,11 @@ def test_split_flag_entry_non_string_is_clean() -> None:
|
||||
|
||||
|
||||
def test_source_kind_map_shape() -> None:
|
||||
"""The kind values the native compile rules key on, and the deliberate
|
||||
AS/ASPP merge (.s and .S both map to asm)."""
|
||||
"""The kind values the native compile rules key on; the AS/ASPP split
|
||||
matches SCons (.S preprocessed, .s plain assembler)."""
|
||||
|
||||
assert set(SOURCE_KIND_FOR_SUFFIX.values()) == {"c", "cxx", "asm"}
|
||||
assert set(SOURCE_KIND_FOR_SUFFIX.values()) == {"c", "cxx", "asm", "aspp"}
|
||||
assert SOURCE_KIND_FOR_SUFFIX[".s"] == "asm"
|
||||
assert SOURCE_KIND_FOR_SUFFIX[".S"] == "asm"
|
||||
assert SOURCE_KIND_FOR_SUFFIX[".S"] == "aspp"
|
||||
assert SOURCE_KIND_FOR_SUFFIX[".c"] == "c"
|
||||
assert SOURCE_KIND_FOR_SUFFIX[".cpp"] == "cxx"
|
||||
|
||||
@@ -2441,3 +2441,39 @@ def test_copy_src_tree_ignores_removed_generated_file(
|
||||
# file was removed and regenerated, not that it triggered sources_changed.
|
||||
new_json = json.loads(build_info_json_path.read_text())
|
||||
assert new_json["config_hash"] == 0xDEADBEEF
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("case", "content", "expected"),
|
||||
[
|
||||
("files missing", None, True),
|
||||
("json missing", "ABSENT", True),
|
||||
("json unreadable", "not json", True),
|
||||
# Valid JSON that is not an object is stale, not an AttributeError
|
||||
("json not an object", "[]", True),
|
||||
("hash mismatch", {"config_hash": 2, "esphome_version": "CURRENT"}, True),
|
||||
("version mismatch", {"config_hash": 1, "esphome_version": "0.0.0"}, True),
|
||||
("matching record", {"config_hash": 1, "esphome_version": "CURRENT"}, False),
|
||||
],
|
||||
)
|
||||
def test_build_info_stale_branches(
|
||||
tmp_path: Path, case: str, content, expected: bool
|
||||
) -> None:
|
||||
"""Missing files, an unreadable JSON, a hash or version mismatch each
|
||||
regenerate; a matching record does not."""
|
||||
from esphome.const import __version__
|
||||
from esphome.writer import _build_info_stale
|
||||
|
||||
h = tmp_path / "build_info_data.h"
|
||||
cpp = tmp_path / "build_info_data.cpp"
|
||||
info = tmp_path / "build_info.json"
|
||||
if content is not None:
|
||||
h.write_text("")
|
||||
cpp.write_text("")
|
||||
if isinstance(content, dict):
|
||||
if content.get("esphome_version") == "CURRENT":
|
||||
content["esphome_version"] = __version__
|
||||
info.write_text(json.dumps(content))
|
||||
elif isinstance(content, str) and content != "ABSENT":
|
||||
info.write_text(content)
|
||||
assert _build_info_stale(h, cpp, info, 1) is expected, case
|
||||
|
||||
Reference in New Issue
Block a user