Skip to content
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
9 changes: 7 additions & 2 deletions tests/unit/cli/test_simplification_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def test_all_sim102_fixes_applied(self):
import subprocess
import sys

first_ccbt_dir = Path(__file__).resolve().parent.parent.parent.parent

result = subprocess.run(
[
sys.executable, "-m", "ruff", "check",
Expand All @@ -245,7 +247,7 @@ def test_all_sim102_fixes_applied(self):
],
check=False, capture_output=True,
text=True,
cwd=Path.cwd(),
cwd=first_ccbt_dir,
)

# Should have no errors (all fixes applied)
Expand All @@ -257,6 +259,9 @@ def test_all_sim105_fixes_applied(self):
import subprocess
import sys

first_ccbt_dir = Path(__file__).resolve().parent.parent.parent.parent


result = subprocess.run(
[
sys.executable, "-m", "ruff", "check",
Expand All @@ -267,7 +272,7 @@ def test_all_sim105_fixes_applied(self):
],
check=False, capture_output=True,
text=True,
cwd=Path.cwd(),
cwd=first_ccbt_dir,
)

# Should have no errors (all fixes applied)
Expand Down
27 changes: 21 additions & 6 deletions tests/unit/performance/test_benchmark_ci_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

from __future__ import annotations

import contextlib
import importlib.util
import json
from functools import wraps
from pathlib import Path
from typing import Any
from typing import Any, Callable

import pytest

Expand All @@ -16,6 +18,17 @@
)


def place_in_cwdr(func : Callable ) -> Callable :
"""Places the tests in the current working directory reguardless of where the tests run from."""
@wraps(func)
def wrapper(* args: Any, **kwargs: Any)-> Any:
base_dir = Path(__file__).resolve().parents[3]
with contextlib.chdir(base_dir):
return func(*args, **kwargs)
return wrapper



def _load_script_module(module_name: str, path: Path):
spec = importlib.util.spec_from_file_location(module_name, str(path))
module = importlib.util.module_from_spec(spec)
Expand All @@ -26,13 +39,15 @@ def _load_script_module(module_name: str, path: Path):


@pytest.fixture(scope="module")
@place_in_cwdr
def benchmark_compare_module() -> Any:
"""Loaded ``dev/scripts/compare_benchmark_json.py`` module."""
path = Path("dev/scripts/compare_benchmark_json.py").resolve()
return _load_script_module("compare_benchmark_json", path)


@pytest.fixture(scope="module")
@place_in_cwdr
def benchmark_render_module() -> Any:
"""Loaded ``dev/scripts/render_benchmark_docs.py`` module."""
path = Path("dev/scripts/render_benchmark_docs.py").resolve()
Expand All @@ -43,7 +58,7 @@ def _load_fixture(path: Path) -> dict[str, Any]:
with path.open("r", encoding="utf-8") as f:
return json.load(f)


@place_in_cwdr
def test_compare_payloads_marks_regressions(benchmark_compare_module) -> None:
"""Head elapsed mean worse than baseline is flagged as regression."""
base_payload = _load_fixture(
Expand Down Expand Up @@ -72,7 +87,7 @@ def test_compare_payloads_marks_regressions(benchmark_compare_module) -> None:
assert comparison["comparisons"][0]["benchmark"] == "hash_verify"
assert comparison["comparisons"][0]["metric"] == "elapsed"


@place_in_cwdr
def test_compare_payloads_identifies_improvement(benchmark_compare_module) -> None:
"""Higher throughput beyond threshold is flagged as improved."""
base_payload = _load_fixture(
Expand All @@ -99,7 +114,7 @@ def test_compare_payloads_identifies_improvement(benchmark_compare_module) -> No
assert comparison["comparisons"][0]["status"] == "improved"
assert comparison["comparisons"][0]["metric"] == "throughput"


@place_in_cwdr
def test_render_latest_and_history_flow(
tmp_path: Path, benchmark_render_module
) -> None:
Expand Down Expand Up @@ -148,7 +163,7 @@ def test_flatten_numeric_samples_nested_lists() -> None:
4.0,
]


@place_in_cwdr
def test_benchmark_scripts_validate() -> None:
"""Benchmark runner scripts must compile before CI executes them."""
validate_module = _load_script_module(
Expand All @@ -157,7 +172,7 @@ def test_benchmark_scripts_validate() -> None:
)
assert validate_module.validate_benchmark_scripts() == []


@place_in_cwdr
def test_run_benchmark_suite_legacy_fallback(tmp_path: Path) -> None:
"""Older benchmark CLIs without --json-out still produce normalized artifacts."""
import sys
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_package_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_version(self):
import ccbt

# Version is defined in ccbt/__init__.py and pyproject.toml
assert ccbt.__version__ == "0.0.1"
assert ccbt.__version__ == "0.1.0"

def test_imports_work(self):
"""Test that main imports work."""
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_safe_event_loop_policy_with_exception(self):

# The exception handling in __init__ should allow import to continue
# Version should be accessible even if policy setup fails
assert ccbt.__version__ == "0.0.1"
assert ccbt.__version__ == "0.1.0"

def test_all_exports(self):
"""Test that __all__ exports are available."""
Expand Down
Loading