mirror of
https://github.com/esphome/esphome.git
synced 2025-10-12 23:03:46 +01:00
uart grouping
This commit is contained in:
@@ -33,6 +33,8 @@ import sys
|
|||||||
COMMON_BUS_PATH = Path("tests/test_build_components/common")
|
COMMON_BUS_PATH = Path("tests/test_build_components/common")
|
||||||
|
|
||||||
# Valid common bus config directories
|
# Valid common bus config directories
|
||||||
|
# All bus types support component grouping for config validation since
|
||||||
|
# --testing-mode bypasses runtime conflicts (we only care that configs compile)
|
||||||
VALID_BUS_CONFIGS = {
|
VALID_BUS_CONFIGS = {
|
||||||
"ble",
|
"ble",
|
||||||
"i2c",
|
"i2c",
|
||||||
@@ -50,28 +52,6 @@ VALID_BUS_CONFIGS = {
|
|||||||
"uart_9600_even",
|
"uart_9600_even",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bus types that support component grouping for config validation
|
|
||||||
# I2C and SPI are shared buses with addressing/CS pins
|
|
||||||
# BLE sensors scan independently and don't conflict
|
|
||||||
# UART is point-to-point but can be grouped for testing since --testing-mode
|
|
||||||
# bypasses the conflict validation (we only care that configs compile)
|
|
||||||
GROUPABLE_BUS_TYPES = {
|
|
||||||
"ble",
|
|
||||||
"i2c",
|
|
||||||
"i2c_low_freq",
|
|
||||||
"qspi",
|
|
||||||
"spi",
|
|
||||||
"uart",
|
|
||||||
"uart_115200",
|
|
||||||
"uart_1200",
|
|
||||||
"uart_1200_even",
|
|
||||||
"uart_19200",
|
|
||||||
"uart_38400",
|
|
||||||
"uart_4800",
|
|
||||||
"uart_4800_even",
|
|
||||||
"uart_9600_even",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def uses_local_file_references(component_dir: Path) -> bool:
|
def uses_local_file_references(component_dir: Path) -> bool:
|
||||||
"""Check if a component uses local file references via $component_dir.
|
"""Check if a component uses local file references via $component_dir.
|
||||||
@@ -204,26 +184,26 @@ def create_grouping_signature(
|
|||||||
"""Create a signature string for grouping components.
|
"""Create a signature string for grouping components.
|
||||||
|
|
||||||
Components with the same signature can be grouped together for testing.
|
Components with the same signature can be grouped together for testing.
|
||||||
Includes groupable bus types (I2C, SPI, BLE, UART) that can be validated
|
All valid bus types can be grouped since --testing-mode bypasses runtime
|
||||||
together using --testing-mode to bypass runtime conflicts.
|
conflicts during config validation.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
platform_buses: Mapping of platform to list of buses
|
platform_buses: Mapping of platform to list of buses
|
||||||
platform: The specific platform to create signature for
|
platform: The specific platform to create signature for
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Signature string (e.g., "i2c" or "uart") or empty if no groupable buses
|
Signature string (e.g., "i2c" or "uart") or empty if no valid buses
|
||||||
"""
|
"""
|
||||||
buses = platform_buses.get(platform, [])
|
buses = platform_buses.get(platform, [])
|
||||||
if not buses:
|
if not buses:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# Only include groupable bus types in signature
|
# Only include valid bus types in signature
|
||||||
groupable_buses = [b for b in buses if b in GROUPABLE_BUS_TYPES]
|
valid_buses = [b for b in buses if b in VALID_BUS_CONFIGS]
|
||||||
if not groupable_buses:
|
if not valid_buses:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return "+".join(sorted(groupable_buses))
|
return "+".join(sorted(valid_buses))
|
||||||
|
|
||||||
|
|
||||||
def group_components_by_signature(
|
def group_components_by_signature(
|
||||||
|
@@ -333,11 +333,11 @@ def run_grouped_component_tests(
|
|||||||
if platform_filter and not platform.startswith(platform_filter):
|
if platform_filter and not platform.startswith(platform_filter):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Only group if component has groupable bus configs
|
# Only group if component has valid bus configs
|
||||||
if buses:
|
if buses:
|
||||||
signature = create_grouping_signature({platform: buses}, platform)
|
signature = create_grouping_signature({platform: buses}, platform)
|
||||||
# Only add to grouped_components if signature is non-empty
|
# Only add to grouped_components if signature is non-empty
|
||||||
# (empty means component has no groupable bus configurations)
|
# (empty means component has no valid bus configurations)
|
||||||
if signature:
|
if signature:
|
||||||
grouped_components[(platform, signature)].append(component)
|
grouped_components[(platform, signature)].append(component)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user