Files
temp/benchmarks/tdd_actor_list_validation_bench.py
hurui200320 1878998b7a refactor(testing): rename tdd_bug/tdd_bug_N tags to tdd_issue/tdd_issue_N
Rename the TDD tag system from tdd_bug/tdd_bug_<N> to tdd_issue/tdd_issue_<N>
across the entire codebase. The tdd_expected_fail tag is unchanged.

The TDD expected-failure workflow is not limited to bug fixes — it applies
equally to any issue type (features, tasks, refactors). The _bug suffix was
misleading and narrowed the perceived scope. The new _issue suffix accurately
reflects that the TDD tagging system applies to any Forgejo issue.

Changes span 92 files:
- features/environment.py: validate_tdd_tags(), should_invert_result(), and
  apply_tdd_inversion() updated — regex, variables, error messages
- robot/tdd_expected_fail_listener.py: _validate_tdd_tags(), _should_invert_result(),
  start_test(), end_test() updated consistently
- 33 Behave .feature files: all @tdd_bug/@tdd_bug_<N> tags renamed
- 29 Robot .robot files: all tdd_bug/tdd_bug_<N> tags renamed
- 3 Robot fixture files renamed (tdd_bug_alone, tdd_missing_tdd_bug,
  tdd_expected_fail_missing_bug_n) with content and references updated
- Tag validation tests and helpers updated (function names, command dispatch
  keys, output strings, fixture references)
- CONTRIBUTING.md: section renamed from 'TDD Bug Test Tags' to
  'TDD Issue Test Tags', all tag references and examples updated
- noxfile.py: comment references updated
- Step definition files, mock helpers, and benchmark files: docstring
  references updated

ISSUES CLOSED: #965
2026-03-27 05:58:35 +00:00

75 lines
2.4 KiB
Python

"""ASV benchmarks for TDD Issue #592 — actor list validation error.
Measures the performance of ``ActorRegistry.list_actors()`` when a provider
has a default model containing ``/`` characters. Establishes a baseline
before and after the bug fix.
Root cause: ``_actor_name()`` builds names via ``f"{provider}/{model}"``.
Multi-slash model names produce actor names with 2+ slashes, which
``ActorService._normalize_name()`` rejects with a ``ValidationError``.
"""
from __future__ import annotations
import contextlib
import sys
from pathlib import Path
from pydantic import ValidationError
# Ensure the local *source* tree is importable even when ASV has an
# older build of the package installed.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
# Ensure the features directory is importable so we can reuse shared
# mock stubs instead of duplicating them locally.
_FEATURES = str(Path(__file__).resolve().parents[1] / "features")
if _FEATURES not in sys.path:
sys.path.insert(0, _FEATURES)
from mocks.fake_provider import FakeProviderInfo, make_registry # noqa: E402
class TDDActorListValidationSuite:
"""Benchmark actor list with multi-slash provider models (TDD issue #592)."""
timeout = 60
def setup(self) -> None:
_, self._empty_registry = make_registry()
_, self._slash_registry = make_registry(
providers=[
FakeProviderInfo(
name="Openrouter",
default_model="anthropic/claude-sonnet-4-20250514",
),
]
)
def time_list_empty(self) -> None:
"""List actors with zero configured providers."""
self._empty_registry.list_actors()
def time_list_multi_slash_provider(self) -> None:
"""List actors when a multi-slash provider is configured."""
with contextlib.suppress(ValidationError):
self._slash_registry.list_actors()
def track_multi_slash_succeeds(self) -> int:
"""Track whether listing with a multi-slash provider succeeds.
Returns 1 when ``list_actors()`` completes without error; 0 if
``ValidationError`` is raised.
"""
try:
self._slash_registry.list_actors()
return 1
except ValidationError:
return 0
_track = TDDActorListValidationSuite.track_multi_slash_succeeds
_track.unit = "success" # type: ignore[attr-defined]