mirror of
https://github.com/esphome/esphome.git
synced 2026-09-21 03:58:41 +00:00
Move core benchmarks to tests/benchmarks/core/
Core is not a component — its benchmarks belong in tests/benchmarks/core/ not tests/benchmarks/components/core/. Add extra_include_dirs parameter to build_and_run to support non-component benchmark directories.
This commit is contained in:
@@ -11,6 +11,9 @@ from test_helpers import PLATFORMIO_GOOGLE_BENCHMARK_LIB, build_and_run
|
||||
# Path to /tests/benchmarks/components
|
||||
BENCHMARKS_DIR: Path = Path(root_path) / "tests" / "benchmarks" / "components"
|
||||
|
||||
# Path to /tests/benchmarks/core (always included, not a component)
|
||||
CORE_BENCHMARKS_DIR: Path = Path(root_path) / "tests" / "benchmarks" / "core"
|
||||
|
||||
# Components whose to_code should run during benchmark builds.
|
||||
# core/host/logger are infrastructure. json is needed because its
|
||||
# to_code adds the ArduinoJson library (it's auto-loaded by api but
|
||||
@@ -37,6 +40,7 @@ def run_benchmarks(selected_components: list[str], build_only: bool = False) ->
|
||||
main_entry="main.cpp",
|
||||
label="benchmarks",
|
||||
build_only=build_only,
|
||||
extra_include_dirs=[CORE_BENCHMARKS_DIR],
|
||||
)
|
||||
|
||||
|
||||
|
||||
+14
-1
@@ -300,6 +300,7 @@ def build_and_run(
|
||||
label: str = "build",
|
||||
build_only: bool = False,
|
||||
extra_run_args: list[str] | None = None,
|
||||
extra_include_dirs: list[Path] | None = None,
|
||||
) -> int:
|
||||
"""Build and optionally run a C++ test/benchmark binary.
|
||||
|
||||
@@ -318,6 +319,8 @@ def build_and_run(
|
||||
label: Label for log messages
|
||||
build_only: If True, print binary path and return without running
|
||||
extra_run_args: Extra arguments to pass to the binary
|
||||
extra_include_dirs: Additional directories (relative to tests_dir)
|
||||
whose .cpp files should be compiled
|
||||
|
||||
Returns:
|
||||
Exit code
|
||||
@@ -339,8 +342,18 @@ def build_and_run(
|
||||
|
||||
components = sorted(components)
|
||||
|
||||
# Build include list: main entry point + component folders
|
||||
# Build include list: main entry point + component folders + extra dirs
|
||||
includes: list[str] = [main_entry] + components
|
||||
if extra_include_dirs:
|
||||
for d in extra_include_dirs:
|
||||
if d.is_dir() and (any(d.glob("*.cpp")) or any(d.glob("*.h"))):
|
||||
# Use path relative to tests_dir for PlatformIO includes
|
||||
try:
|
||||
rel = d.relative_to(tests_dir)
|
||||
includes.append(str(rel))
|
||||
except ValueError:
|
||||
# Not relative to tests_dir, use absolute
|
||||
includes.append(str(d))
|
||||
|
||||
# Discover platform sub-components
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user