mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:27:14 +00:00
[ci] Add validate.*.yaml for config-only component tests (#16384)
This commit is contained in:
@@ -117,7 +117,7 @@ def get_component_from_path(file_path: str) -> str | None:
|
||||
|
||||
|
||||
def get_component_test_files(
|
||||
component: str, *, all_variants: bool = False
|
||||
component: str, *, all_variants: bool = False, include_validate: bool = False
|
||||
) -> list[Path]:
|
||||
"""Get test files for a component.
|
||||
|
||||
@@ -126,6 +126,10 @@ def get_component_test_files(
|
||||
all_variants: If True, returns all test files including variants (test-*.yaml).
|
||||
If False, returns only base test files (test.*.yaml).
|
||||
Default is False.
|
||||
include_validate: If True, also returns config-only files (validate.*.yaml,
|
||||
and validate-*.yaml when all_variants is True). These files
|
||||
are validated with `esphome config` but never compiled.
|
||||
Default is False.
|
||||
|
||||
Returns:
|
||||
List of test file paths for the component, or empty list if none exist
|
||||
@@ -136,9 +140,27 @@ def get_component_test_files(
|
||||
|
||||
if all_variants:
|
||||
# Match both test.*.yaml and test-*.yaml patterns
|
||||
return list(tests_dir.glob("test[.-]*.yaml"))
|
||||
files = list(tests_dir.glob("test[.-]*.yaml"))
|
||||
if include_validate:
|
||||
files.extend(tests_dir.glob("validate[.-]*.yaml"))
|
||||
return files
|
||||
# Match only test.*.yaml (base tests)
|
||||
return list(tests_dir.glob("test.*.yaml"))
|
||||
files = list(tests_dir.glob("test.*.yaml"))
|
||||
if include_validate:
|
||||
files.extend(tests_dir.glob("validate.*.yaml"))
|
||||
return files
|
||||
|
||||
|
||||
def is_validate_only_file(test_file: Path) -> bool:
|
||||
"""Return True if the given path is a config-only validate file.
|
||||
|
||||
Validate files follow the same grammar as test files but with a
|
||||
``validate`` prefix instead of ``test``: ``validate.<platform>.yaml``
|
||||
or ``validate-<variant>.<platform>.yaml``. They are exercised with
|
||||
``esphome config`` only and skipped during compile.
|
||||
"""
|
||||
name = test_file.name
|
||||
return name.startswith("validate.") or name.startswith("validate-")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
Reference in New Issue
Block a user