02c75fb4bb
Add structured data builders and Rich renderers for version, info, and diagnostics commands. Support --format rich/plain/json/yaml output parity and --check flag for diagnostics (exits non-zero on errors). Includes Behave scenarios, Robot smoke tests, ASV benchmarks, and updates existing tests to match the new Rich panel output format.
96 lines
2.8 KiB
Python
96 lines
2.8 KiB
Python
"""ASV benchmarks for enhanced CLI core system commands.
|
|
|
|
Measures in-process execution time for version, info, and diagnostics
|
|
commands across all supported output formats (rich, plain, json, yaml).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
try:
|
|
from cleveragents.cli.commands.system import (
|
|
build_diagnostics_data,
|
|
build_info_data,
|
|
build_version_data,
|
|
)
|
|
from cleveragents.cli.formatting import format_output
|
|
except ModuleNotFoundError:
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
from cleveragents.cli.commands.system import (
|
|
build_diagnostics_data,
|
|
build_info_data,
|
|
build_version_data,
|
|
)
|
|
from cleveragents.cli.formatting import format_output
|
|
|
|
|
|
class VersionSuite:
|
|
"""Benchmark version data assembly and formatting."""
|
|
|
|
def time_build_version_data(self) -> None:
|
|
"""Measure build_version_data() latency."""
|
|
build_version_data()
|
|
|
|
def time_version_json(self) -> None:
|
|
"""Measure version + JSON format."""
|
|
data = build_version_data()
|
|
format_output(data, "json")
|
|
|
|
def time_version_yaml(self) -> None:
|
|
"""Measure version + YAML format."""
|
|
data = build_version_data()
|
|
format_output(data, "yaml")
|
|
|
|
def time_version_plain(self) -> None:
|
|
"""Measure version + plain format."""
|
|
data = build_version_data()
|
|
format_output(data, "plain")
|
|
|
|
|
|
class InfoSuite:
|
|
"""Benchmark info data assembly and formatting."""
|
|
|
|
def time_build_info_data(self) -> None:
|
|
"""Measure build_info_data() latency."""
|
|
build_info_data()
|
|
|
|
def time_info_json(self) -> None:
|
|
"""Measure info + JSON format."""
|
|
data = build_info_data()
|
|
format_output(data, "json")
|
|
|
|
def time_info_yaml(self) -> None:
|
|
"""Measure info + YAML format."""
|
|
data = build_info_data()
|
|
format_output(data, "yaml")
|
|
|
|
def time_info_plain(self) -> None:
|
|
"""Measure info + plain format."""
|
|
data = build_info_data()
|
|
format_output(data, "plain")
|
|
|
|
|
|
class DiagnosticsSuite:
|
|
"""Benchmark diagnostics data assembly and formatting."""
|
|
|
|
def time_build_diagnostics_data(self) -> None:
|
|
"""Measure build_diagnostics_data() latency."""
|
|
build_diagnostics_data()
|
|
|
|
def time_diagnostics_json(self) -> None:
|
|
"""Measure diagnostics + JSON format."""
|
|
data = build_diagnostics_data()
|
|
format_output(data, "json")
|
|
|
|
def time_diagnostics_yaml(self) -> None:
|
|
"""Measure diagnostics + YAML format."""
|
|
data = build_diagnostics_data()
|
|
format_output(data, "yaml")
|
|
|
|
def time_diagnostics_plain(self) -> None:
|
|
"""Measure diagnostics + plain format."""
|
|
data = build_diagnostics_data()
|
|
format_output(data, "plain")
|