mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
[ci] Lint log tags in headers and core (#20668)
This commit is contained in:
@@ -400,6 +400,7 @@ def test_ternary_error_message_names_the_literal() -> None:
|
||||
'static constexpr char TAG[] = {"x"};',
|
||||
'static const char TAG[8] = "x";',
|
||||
' static const char *const TAG = "x";',
|
||||
'constexpr static const char *const TAG = "x";',
|
||||
],
|
||||
)
|
||||
def test_log_tag_macro_flags_plain_tags(line: str) -> None:
|
||||
@@ -408,12 +409,37 @@ def test_log_tag_macro_flags_plain_tags(line: str) -> None:
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"line",
|
||||
['ESPHOME_LOG_TAG(TAG, "x");', 'static const char *const NAME = "x";'],
|
||||
[
|
||||
'ESPHOME_LOG_TAG(TAG, "x");',
|
||||
'static const char *const NAME = "x";',
|
||||
'static const char *const TAG = "x"; // NOLINT',
|
||||
],
|
||||
)
|
||||
def test_log_tag_macro_ignores_macro_and_other_names(line: str) -> None:
|
||||
assert not ci_custom.lint_log_tag_macro("test.cpp", line + "\n")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("fname", "covered"),
|
||||
[
|
||||
("esphome/components/x/x.cpp", True),
|
||||
("esphome/components/x/x.h", True),
|
||||
("esphome/components/x/sub/x.h", True),
|
||||
("esphome/core/wake/wake_host.cpp", True),
|
||||
("esphome/components/x/x.c", False),
|
||||
],
|
||||
)
|
||||
def test_log_tag_lints_cover_headers_and_core(fname: str, covered: bool) -> None:
|
||||
for name, line in (
|
||||
("lint_log_tag_macro", 'static const char *const TAG = "x";\n'),
|
||||
("lint_log_tag_as_string", "strcmp(TAG, name);\n"),
|
||||
):
|
||||
lint = next(
|
||||
c for c in ci_custom.LINT_CONTENT_CHECKS if c["func"].__name__ == name
|
||||
)
|
||||
assert bool(ci_custom.run_check(lint, fname, fname, line)) is covered
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"line",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user