Skip to content

Commit db4a2c5

Browse files
committed
refactor: split eval loading helpers
Separate fixture diff resolution from repo-path resolution so execution setup can change each concern independently. Made-with: Cursor
1 parent 610b96f commit db4a2c5

File tree

4 files changed

+51
-37
lines changed

4 files changed

+51
-37
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
- [x] `src/commands/doctor/command/display.rs`: separate header/config output, endpoint listing, and inference result rendering.
7272
- [x] `src/commands/doctor/command/run.rs`: separate endpoint discovery, recommendation flow, and test helpers.
7373
- [x] `src/commands/eval/runner/matching.rs`: split required-match search, unexpected-match detection, and rule metric assembly.
74-
- [ ] `src/commands/eval/runner/execute/loading.rs`: separate diff resolution from repo-path resolution if it grows again.
74+
- [x] `src/commands/eval/runner/execute/loading.rs`: separate diff resolution from repo-path resolution if it grows again.
7575
- [ ] `src/commands/feedback_eval/report/examples.rs`: split ranking helpers from example builders.
7676
- [ ] `src/commands/doctor/system.rs`: carve environment probes vs output helpers.
7777

src/commands/eval/runner/execute/loading.rs

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
#[path = "loading/diff.rs"]
2+
mod diff;
3+
#[path = "loading/repo.rs"]
4+
mod repo;
5+
16
use anyhow::Result;
27
use std::path::{Path, PathBuf};
38

49
use crate::core::eval_benchmarks::{BenchmarkThresholds, Difficulty};
510

611
use super::super::super::{EvalFixture, LoadedEvalFixture};
12+
use diff::load_diff_content;
13+
use repo::resolve_repo_path;
714

815
pub(super) struct PreparedFixtureExecution {
916
pub(super) fixture_name: String,
@@ -49,39 +56,3 @@ pub(super) fn prepare_fixture_execution(
4956
repo_path,
5057
})
5158
}
52-
53-
fn load_diff_content(
54-
fixture_name: &str,
55-
fixture_dir: &Path,
56-
fixture: &EvalFixture,
57-
) -> Result<String> {
58-
match (fixture.diff.clone(), fixture.diff_file.clone()) {
59-
(Some(diff), _) => Ok(diff),
60-
(None, Some(diff_file)) => {
61-
let path = if diff_file.is_absolute() {
62-
diff_file
63-
} else {
64-
fixture_dir.join(diff_file)
65-
};
66-
Ok(std::fs::read_to_string(path)?)
67-
}
68-
(None, None) => anyhow::bail!(
69-
"Fixture '{}' must define either diff or diff_file",
70-
fixture_name
71-
),
72-
}
73-
}
74-
75-
fn resolve_repo_path(fixture_dir: &Path, fixture: &EvalFixture) -> PathBuf {
76-
fixture
77-
.repo_path
78-
.clone()
79-
.map(|path| {
80-
if path.is_absolute() {
81-
path
82-
} else {
83-
fixture_dir.join(path)
84-
}
85-
})
86-
.unwrap_or_else(|| PathBuf::from("."))
87-
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use anyhow::Result;
2+
use std::path::Path;
3+
4+
use super::super::super::super::EvalFixture;
5+
6+
pub(super) fn load_diff_content(
7+
fixture_name: &str,
8+
fixture_dir: &Path,
9+
fixture: &EvalFixture,
10+
) -> Result<String> {
11+
match (fixture.diff.clone(), fixture.diff_file.clone()) {
12+
(Some(diff), _) => Ok(diff),
13+
(None, Some(diff_file)) => {
14+
let path = if diff_file.is_absolute() {
15+
diff_file
16+
} else {
17+
fixture_dir.join(diff_file)
18+
};
19+
Ok(std::fs::read_to_string(path)?)
20+
}
21+
(None, None) => anyhow::bail!(
22+
"Fixture '{}' must define either diff or diff_file",
23+
fixture_name
24+
),
25+
}
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::path::{Path, PathBuf};
2+
3+
use super::super::super::super::EvalFixture;
4+
5+
pub(super) fn resolve_repo_path(fixture_dir: &Path, fixture: &EvalFixture) -> PathBuf {
6+
fixture
7+
.repo_path
8+
.clone()
9+
.map(|path| {
10+
if path.is_absolute() {
11+
path
12+
} else {
13+
fixture_dir.join(path)
14+
}
15+
})
16+
.unwrap_or_else(|| PathBuf::from("."))
17+
}

0 commit comments

Comments
 (0)