llm_git/testing/mod.rs
1//! Testing infrastructure for llm-git
2//!
3//! Provides fixture-based golden file testing for commit message generation.
4//!
5//! # Directory Structure
6//!
7//! ```text
8//! tests/fixtures/
9//! ├── manifest.toml # Fixture registry
10//! ├── large-wasm-merge/
11//! │ ├── meta.toml # Fixture metadata
12//! │ ├── input/
13//! │ │ ├── diff.patch # Frozen diff
14//! │ │ ├── stat.txt # Frozen stat
15//! │ │ ├── scope_candidates.txt
16//! │ │ └── context.toml # Analysis context
17//! │ └── golden/
18//! │ ├── analysis.json # Expected analysis
19//! │ └── final.txt # Expected commit message
20//! └── ...
21//! ```
22
23mod compare;
24pub mod fixture;
25mod report;
26mod runner;
27
28use std::path::Path;
29
30pub use compare::{CompareResult, compare_analysis};
31pub use fixture::{
32 Fixture, FixtureContext, FixtureEntry, FixtureInput, FixtureMeta, Golden, Manifest,
33 discover_fixtures,
34};
35pub use report::generate_html_report;
36pub use runner::{RunResult, TestRunner, TestSummary};
37
38use crate::error::Result;
39
40/// Default fixtures directory relative to crate root
41pub const FIXTURES_DIR: &str = "tests/fixtures";
42
43/// Get the fixtures directory path
44pub fn fixtures_dir() -> std::path::PathBuf {
45 // Try to find it relative to CARGO_MANIFEST_DIR or current dir
46 if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
47 return Path::new(&manifest_dir).join(FIXTURES_DIR);
48 }
49
50 // Fall back to current directory
51 Path::new(FIXTURES_DIR).to_path_buf()
52}
53
54/// List all available fixtures
55pub fn list_fixtures() -> Result<Vec<String>> {
56 let manifest = Manifest::load(&fixtures_dir())?;
57 Ok(manifest.fixtures.into_keys().collect())
58}