mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
* wip * refactor(tests): move sdk function tracing into rust python harness * dead code * fix: handle harness keyboard interrupts * refactor(tests): deduplicate rust python harness helpers * fix(harness): expose validated strategy choices * wip * refactor(harness): let strategies own parity reports * docs(harness): update strategy structure * refactor(harness): localize strategy report views * wip * fix(harness): satisfy mapping runner type checks * fix(harness): clarify trace parity output * wip * fix(harness): clarify unit mapping report * fix(harness): finalize trace parity contracts * refactor(harness): structure parity contracts * feat: derive unit test mapping from traces * feat(harness): map rstest test families * feat(ocr): port Azure document intelligence tests * feat(harness): enforce complete unit mappings * feat(ocr): add reducto core transforms * feat(harness): classify host-only unit tests * fix(ocr): complete Rust provider plumbing * fix(harness): reuse OCR parity workers
55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
from collections.abc import Callable
|
|
from pathlib import Path
|
|
from typing import Final
|
|
|
|
import pytest
|
|
|
|
from ...shared.reporting.models import Coverage, HarnessCase, RunStatus
|
|
from ...shared.reporting.strategy import SuiteCaseSpec
|
|
from ...shared.unit_runners.suite_runner import run_suites
|
|
from .runner import RustSuite, run_suite
|
|
|
|
|
|
@pytest.mark.skipif(shutil.which("cargo") is None, reason="Cargo is required for the native unit strategy")
|
|
def test_runs_cargo_tests_and_propagates_ignored_or_failing_tests(
|
|
tmp_path: Path,
|
|
cargo_project: Callable[[str, str], Path],
|
|
) -> None:
|
|
cargo_project("rust-unit-check", '#[test] fn test_decode() { assert_eq!("42".parse::<u8>().unwrap(), 42); }\n')
|
|
rust_root: Final = tmp_path / "litellm-rust"
|
|
rust_root.mkdir()
|
|
(tmp_path / "Cargo.toml").rename(rust_root / "Cargo.toml")
|
|
(tmp_path / "src").rename(rust_root / "src")
|
|
suite: Final = RustSuite(
|
|
cargo_manifest="litellm-rust/Cargo.toml",
|
|
cargo_filter="test_decode",
|
|
)
|
|
case: Final = HarnessCase(
|
|
strategy_id="unit_tests_rust",
|
|
strategy_label="Unit test Rust",
|
|
sdk_function="ocr",
|
|
spec=SuiteCaseSpec(coverage=Coverage.COMPLETE, suite="ocr"),
|
|
)
|
|
|
|
code, report = run_suites((case,), tmp_path, lambda _: None, suites={"ocr": suite}, execute=run_suite)
|
|
|
|
assert code == 0, report.failures
|
|
assert report.results[case.key].status is RunStatus.PASSED
|
|
|
|
(rust_root / "src/lib.rs").write_text("#[test] #[ignore] fn test_decode() {}\n")
|
|
ignored_code, ignored_report = run_suites(
|
|
(case,), tmp_path, lambda _: None, suites={"ocr": suite}, execute=run_suite
|
|
)
|
|
|
|
assert ignored_code == 1
|
|
assert any("native Rust tests did not all pass" in detail for _, detail in ignored_report.failures)
|
|
|
|
(rust_root / "src/lib.rs").write_text("#[test] fn test_decode() { assert_eq!(2 + 2, 5); }\n")
|
|
failed_code, failed_report = run_suites((case,), tmp_path, lambda _: None, suites={"ocr": suite}, execute=run_suite)
|
|
|
|
assert failed_code == 1
|
|
assert failed_report.results[case.key].status is RunStatus.FAILED
|
|
assert any("test_decode" in detail for _, detail in failed_report.failures)
|