Skip to content

Commit c594817

Browse files
committed
windows working. fix test helper
1 parent df9c415 commit c594817

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

tests/ai_tab.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -350,24 +350,17 @@ fn test_ai_tab_e2e_handles_dirty_files_map() {
350350
}),
351351
);
352352

353-
// // Debug: Check working logs before commit
354-
// let working_logs = repo.current_working_logs();
355-
// if let Ok(checkpoints) = working_logs.read_all_checkpoints() {
356-
// println!("Checkpoints before commit: {}", checkpoints.len());
357-
// for (i, cp) in checkpoints.iter().enumerate() {
358-
// println!("Checkpoint {}: kind={:?}, entries={}", i, cp.kind, cp.entries.len());
359-
// for entry in &cp.entries {
360-
// println!(" File: {}, attributions={}", entry.file, entry.attributions.len());
361-
// }
362-
// }
363-
// }
364353

365354
let working_logs = repo.current_working_logs();
366355
println!("dirty_files: {:?}", working_logs.dirty_files);
367356

368-
repo.stage_all_and_commit("Record AI tab completion while other files dirty").unwrap();
357+
let commit_result = repo.stage_all_and_commit("Record AI tab completion while other files dirty").unwrap();
358+
println!("COMMIT OUTPUT: {}", commit_result.stdout);
369359

370-
let mut file = repo.filename(&std::path::Path::new("src").join("lib.rs").to_string_lossy());
360+
361+
commit_result.print_authorship();
362+
363+
let mut file = repo.filename("src/lib.rs");
371364
file.assert_lines_and_blame(lines![
372365
"fn greet() {".human(),
373366
" println!(\"hello\");".human(),

tests/repos/test_file.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ impl<'a> TestFile<'a> {
120120
};
121121
}
122122

123-
// Run blame to get authorship
124-
let filename = file_path.to_str().expect("valid path");
123+
// Run blame to get authorship - use relative path from repo root
124+
let filename = file_path
125+
.strip_prefix(&repo.path)
126+
.expect("file path should be within repo")
127+
.to_str()
128+
.expect("valid path");
125129
let blame_result = repo.git_ai(&["blame", filename]);
126130

127131
let lines = if let Ok(blame_output) = blame_result {
@@ -213,7 +217,11 @@ impl<'a> TestFile<'a> {
213217
}
214218

215219
pub fn assert_blame_snapshot(&self) {
216-
let filename = self.file_path.to_str().expect("valid path");
220+
let filename = self.file_path
221+
.strip_prefix(&self.repo.path)
222+
.expect("file path should be within repo")
223+
.to_str()
224+
.expect("valid path");
217225
let blame_output = self
218226
.repo
219227
.git_ai(&["blame", filename])
@@ -226,8 +234,12 @@ impl<'a> TestFile<'a> {
226234
pub fn assert_lines_and_blame<T: Into<ExpectedLine>>(&mut self, lines: Vec<T>) {
227235
let expected_lines: Vec<ExpectedLine> = lines.into_iter().map(|l| l.into()).collect();
228236

229-
// Get blame output
230-
let filename = self.file_path.to_str().expect("valid path");
237+
// Get blame output - use relative path from repo root
238+
let filename = self.file_path
239+
.strip_prefix(&self.repo.path)
240+
.expect("file path should be within repo")
241+
.to_str()
242+
.expect("valid path");
231243
let blame_output = self
232244
.repo
233245
.git_ai(&["blame", filename])
@@ -300,8 +312,12 @@ impl<'a> TestFile<'a> {
300312
pub fn assert_committed_lines<T: Into<ExpectedLine>>(&mut self, lines: Vec<T>) {
301313
let expected_lines: Vec<ExpectedLine> = lines.into_iter().map(|l| l.into()).collect();
302314

303-
// Get blame output
304-
let filename = self.file_path.to_str().expect("valid path");
315+
// Get blame output - use relative path from repo root
316+
let filename = self.file_path
317+
.strip_prefix(&self.repo.path)
318+
.expect("file path should be within repo")
319+
.to_str()
320+
.expect("valid path");
305321
let blame_output = self
306322
.repo
307323
.git_ai(&["blame", filename])
@@ -430,8 +446,12 @@ impl<'a> TestFile<'a> {
430446

431447
/// Assert that the file at the given path matches the expected contents and authorship
432448
pub fn assert_blame_contents_expected(&self) {
433-
// Get blame output
434-
let filename = self.file_path.to_str().expect("valid path");
449+
// Get blame output - use relative path from repo root
450+
let filename = self.file_path
451+
.strip_prefix(&self.repo.path)
452+
.expect("file path should be within repo")
453+
.to_str()
454+
.expect("valid path");
435455
let blame_output = self
436456
.repo
437457
.git_ai(&["blame", filename])

tests/repos/test_repo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::test_file::TestFile;
1414

1515
#[derive(Clone, Debug)]
1616
pub struct TestRepo {
17-
path: PathBuf,
17+
pub path: PathBuf,
1818
}
1919

2020
impl TestRepo {
@@ -216,7 +216,7 @@ impl TestRepo {
216216
}
217217

218218
pub fn stage_all_and_commit(&self, message: &str) -> Result<NewCommit, String> {
219-
self.git(&["add", "-A"]).expect("add --all should succeed");
219+
println!("stage_all_and_commit: {:?}", self.git(&["add", "-A"]).expect("add --all should succeed"));
220220
self.commit(message)
221221
}
222222

0 commit comments

Comments
 (0)