From 8d801e8b76e1e04d3686462b2939681692a12b76 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 7 Feb 2023 07:23:52 +0100 Subject: [PATCH] Add a cache for the FindBinary method of scripts/tests/run_test_suite.py in order to not wait for too long each time it is runned manually (#24882) --- scripts/requirements.txt | 3 +++ scripts/tests/run_test_suite.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/scripts/requirements.txt b/scripts/requirements.txt index eb7b423cd90b05..6a0ba5162d2ff0 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -81,3 +81,6 @@ colorama # update tornado for pw_watch tornado + +# YAML test harness +diskcache diff --git a/scripts/tests/run_test_suite.py b/scripts/tests/run_test_suite.py index ba3deb1899f112..d4963f1623d1fd 100755 --- a/scripts/tests/run_test_suite.py +++ b/scripts/tests/run_test_suite.py @@ -18,6 +18,7 @@ import logging import os import sys +import tempfile import time import typing from dataclasses import dataclass, field @@ -29,6 +30,9 @@ from chiptest.accessories import AppsRegister from chiptest.glob_matcher import GlobMatcher from chiptest.test_definition import TestRunTime, TestTag +from diskcache import Cache + +cache = Cache(os.path.join(tempfile.gettempdir(), 'yaml_runner_cache')) DEFAULT_CHIP_ROOT = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..')) @@ -41,11 +45,20 @@ class ManualHandling(enum.Enum): def FindBinaryPath(name: str): + binary_path = cache.get(name) + if binary_path: + if Path(binary_path).is_file(): + return binary_path + else: + del cache[name] + + start = time.time() for path in Path(DEFAULT_CHIP_ROOT).rglob(name): if not path.is_file(): continue if path.name != name: continue + cache[name] = str(path) return str(path) return 'NOT_FOUND_IN_OUTPUT_' + name