1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-12 14:53:49 +01:00
This commit is contained in:
J. Nick Koston
2025-10-08 16:25:53 -10:00
parent 4406dc6b2a
commit e5adfd956a
5 changed files with 26 additions and 27 deletions

View File

@@ -1003,8 +1003,8 @@ def parse_args(argv):
default=[],
)
options_parser.add_argument(
"--ignore-pin-conflicts",
help="Disable pin conflict validation (for testing grouped components)",
"--testing-mode",
help="Enable testing mode (disables validation checks for grouped component testing)",
action="store_true",
default=False,
)
@@ -1266,7 +1266,7 @@ def run_esphome(argv):
args = parse_args(argv)
CORE.dashboard = args.dashboard
CORE.ignore_pin_conflicts = args.ignore_pin_conflicts
CORE.testing_mode = args.testing_mode
# Create address cache from command-line arguments
CORE.address_cache = AddressCache.from_cli_args(

View File

@@ -529,8 +529,8 @@ class EsphomeCore:
self.dashboard = False
# True if command is run from vscode api
self.vscode = False
# True if pin conflict validation should be ignored
self.ignore_pin_conflicts = False
# True if running in testing mode (disables validation checks for grouped testing)
self.testing_mode = False
# The name of the node
self.name: str | None = None
# The friendly name of the node

View File

@@ -246,6 +246,9 @@ def entity_duplicate_validator(platform: str) -> Callable[[ConfigType], ConfigTy
"\n to distinguish them"
)
# Skip duplicate entity name validation when testing_mode is enabled
# This flag is used for grouped component testing
if not CORE.testing_mode:
raise cv.Invalid(
f"Duplicate {platform} entity with name '{entity_name}' found{device_prefix}. "
f"{conflict_msg}. "

View File

@@ -118,11 +118,7 @@ class PinRegistry(dict):
parent_config = fconf.get_config_for_path(parent_path)
final_val_fun(pin_config, parent_config)
allow_others = pin_config.get(CONF_ALLOW_OTHER_USES, False)
if (
count != 1
and not allow_others
and not CORE.ignore_pin_conflicts
):
if count != 1 and not allow_others and not CORE.testing_mode:
raise cv.Invalid(
f"Pin {pin_config[CONF_NUMBER]} is used in multiple places"
)

View File

@@ -9,7 +9,7 @@ Features:
- Analyzes components for shared common bus configs
- Groups compatible components together
- Merges configs for grouped components
- Uses --ignore-pin-conflicts for grouped tests
- Uses --testing-mode for grouped tests
- Maintains backward compatibility with single component testing
"""
@@ -119,7 +119,7 @@ def run_esphome_test(
build_dir: Path,
esphome_command: str,
continue_on_fail: bool,
use_ignore_pin_conflicts: bool = False,
use_testing_mode: bool = False,
) -> bool:
"""Run esphome test for a single component.
@@ -132,7 +132,7 @@ def run_esphome_test(
build_dir: Path to build directory
esphome_command: ESPHome command (config/compile)
continue_on_fail: Whether to continue on failure
use_ignore_pin_conflicts: Whether to use --ignore-pin-conflicts flag
use_testing_mode: Whether to use --testing-mode flag
Returns:
True if test passed, False otherwise
@@ -157,9 +157,9 @@ def run_esphome_test(
"esphome",
]
# Add --ignore-pin-conflicts if needed (must be before subcommand)
if use_ignore_pin_conflicts:
cmd.append("--ignore-pin-conflicts")
# Add --testing-mode if needed (must be before subcommand)
if use_testing_mode:
cmd.append("--testing-mode")
# Add substitutions
cmd.extend(
@@ -184,8 +184,8 @@ def run_esphome_test(
# Run command
print(f"> [{component}] [{test_name}] [{platform_with_version}]")
if use_ignore_pin_conflicts:
print(" (using --ignore-pin-conflicts)")
if use_testing_mode:
print(" (using --testing-mode)")
try:
result = subprocess.run(cmd, check=not continue_on_fail)
@@ -248,12 +248,12 @@ def run_grouped_test(
output_content = base_content.replace("$component_test_file", merged_ref)
output_file.write_text(output_content)
# Build esphome command with --ignore-pin-conflicts
# Build esphome command with --testing-mode
cmd = [
sys.executable,
"-m",
"esphome",
"--ignore-pin-conflicts", # Required for grouped tests
"--testing-mode", # Required for grouped tests
"-s",
"component_name",
group_name,
@@ -273,7 +273,7 @@ def run_grouped_test(
# Run command
components_str = ", ".join(components)
print(f"> [GROUPED: {components_str}] [{platform_with_version}]")
print(" (using --ignore-pin-conflicts)")
print(" (using --testing-mode)")
try:
result = subprocess.run(cmd, check=not continue_on_fail)