Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cache for the FindBinary method of scripts/tests/run_test_suite… #24882

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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