Files
wehub-resource-sync 4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

90 lines
2.5 KiB
Python

from __future__ import annotations
import shlex
from dataclasses import dataclass, field
@dataclass(frozen=True)
class TestRequirement:
env_vars: tuple[str, ...] = ()
notes: tuple[str, ...] = ()
def summary(self) -> str:
parts: list[str] = []
if self.env_vars:
parts.append("env:" + ",".join(self.env_vars))
parts.extend(self.notes)
return " | ".join(parts)
@dataclass(frozen=True)
class TestCatalogItem:
id: str
kind: str
display_name: str
description: str
command: tuple[str, ...] = ()
tags: tuple[str, ...] = ()
source_path: str = ""
requirements: TestRequirement = field(default_factory=TestRequirement)
children: tuple[TestCatalogItem, ...] = ()
@property
def command_display(self) -> str:
return shlex.join(self.command) if self.command else ""
@property
def is_runnable(self) -> bool:
return bool(self.command)
def matches(self, *, category: str = "all", search: str = "") -> bool:
if category != "all" and category not in self.tags:
return False
if not search:
return True
query = search.lower()
searchable = " ".join(
[
self.id,
self.display_name,
self.description,
" ".join(self.tags),
self.source_path,
]
).lower()
return query in searchable
def iter_items(items: tuple[TestCatalogItem, ...]) -> list[TestCatalogItem]:
flattened: list[TestCatalogItem] = []
for item in items:
flattened.append(item)
if item.children:
flattened.extend(iter_items(item.children))
return flattened
@dataclass(frozen=True)
class TestCatalog:
items: tuple[TestCatalogItem, ...]
def all_items(self) -> list[TestCatalogItem]:
return iter_items(self.items)
def find(self, item_id: str) -> TestCatalogItem | None:
for item in self.all_items():
if item.id == item_id:
return item
return None
def filter(self, *, category: str = "all", search: str = "") -> list[TestCatalogItem]:
matched: list[TestCatalogItem] = []
for item in self.items:
if item.matches(category=category, search=search):
matched.append(item)
continue
if any(child.matches(category=category, search=search) for child in item.children):
matched.append(item)
return matched