diff --git a/esphome/analyze_memory/__init__.py b/esphome/analyze_memory/__init__.py index b8bbd68df2..07f8df8767 100644 --- a/esphome/analyze_memory/__init__.py +++ b/esphome/analyze_memory/__init__.py @@ -2,7 +2,6 @@ from collections import defaultdict from dataclasses import dataclass, field -import json import logging from pathlib import Path import re @@ -422,28 +421,6 @@ class MemoryAnalyzer: return "Other Core" - def to_json(self) -> str: - """Export analysis results as JSON.""" - data = { - "components": { - name: { - "text": mem.text_size, - "rodata": mem.rodata_size, - "data": mem.data_size, - "bss": mem.bss_size, - "flash_total": mem.flash_total, - "ram_total": mem.ram_total, - "symbol_count": mem.symbol_count, - } - for name, mem in self.components.items() - }, - "totals": { - "flash": sum(c.flash_total for c in self.components.values()), - "ram": sum(c.ram_total for c in self.components.values()), - }, - } - return json.dumps(data, indent=2) - if __name__ == "__main__": from .cli import main diff --git a/script/determine-jobs.py b/script/determine-jobs.py index d4b46e5474..befd75fb5b 100755 --- a/script/determine-jobs.py +++ b/script/determine-jobs.py @@ -54,6 +54,7 @@ from helpers import ( changed_files, get_all_dependencies, get_components_from_integration_fixtures, + parse_test_filename, root_path, ) @@ -335,11 +336,8 @@ def detect_memory_impact_config( # Check if component has tests for any preferred platform available_platforms = [] for test_file in test_files: - parts = test_file.stem.split(".") - if len(parts) < 2: - continue - platform = parts[1] - if platform in PLATFORM_PREFERENCE: + _, platform = parse_test_filename(test_file) + if platform != "all" and platform in PLATFORM_PREFERENCE: available_platforms.append(platform) if not available_platforms: diff --git a/script/helpers.py b/script/helpers.py index 61306b9489..85e568dcf8 100644 --- a/script/helpers.py +++ b/script/helpers.py @@ -46,6 +46,23 @@ def parse_list_components_output(output: str) -> list[str]: return [c.strip() for c in output.strip().split("\n") if c.strip()] +def parse_test_filename(test_file: Path) -> tuple[str, str]: + """Parse test filename to extract test name and platform. + + Test files follow the naming pattern: test..yaml or test-..yaml + + Args: + test_file: Path to test file + + Returns: + Tuple of (test_name, platform) + """ + parts = test_file.stem.split(".") + if len(parts) == 2: + return parts[0], parts[1] # test, platform + return parts[0], "all" + + def styled(color: str | tuple[str, ...], msg: str, reset: bool = True) -> str: prefix = "".join(color) if isinstance(color, tuple) else color suffix = colorama.Style.RESET_ALL if reset else ""