Skip to content

Commit

Permalink
Add a cache for the FindBinary method of scripts/tests/run_test_suite…
Browse files Browse the repository at this point in the history
….py in order to not wait for too long each time it is runned manually (#24882)
  • Loading branch information
vivien-apple authored and pull[bot] committed Sep 20, 2023
1 parent 75224fd commit 72188c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ colorama

# update tornado for pw_watch
tornado

# YAML test harness
diskcache
13 changes: 13 additions & 0 deletions scripts/tests/run_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
import os
import sys
import tempfile
import time
import typing
from dataclasses import dataclass, field
Expand All @@ -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__), '..', '..'))
Expand All @@ -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
Expand Down

0 comments on commit 72188c8

Please sign in to comment.