Skip to content

Commit

Permalink
Include column in log file names
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Dec 4, 2023
1 parent b987852 commit 84449a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,14 @@ impl Mutant {
.with_context(|| format!("failed to write mutated code to {path:?}"))
}

/// Return a string describing this mutant that's suitable for building a log file name,
/// but can contain slashes.
pub fn log_file_name_base(&self) -> String {
format!(
"{}_line_{}",
self.source_file.tree_relative_slashes(),
self.span.start.line,
"{filename}_line_{line}_col_{col}",
filename = self.source_file.tree_relative_slashes(),
line = self.span.start.line,
col = self.span.start.column,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ fn small_well_tested_tree_is_clean() {
let log_content = fs::read_to_string(
tmp_src_dir
.path()
.join("mutants.out/log/src__lib.rs_line_5.log"),
.join("mutants.out/log/src__lib.rs_line_5_col_5.log"),
)
.unwrap()
.replace('\r', "");
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/snapshots/cli__factorial__log_names.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: "&names"
---
[
"baseline.log",
"src__bin__factorial.rs_line_2.log",
"src__bin__factorial.rs_line_8.log",
"src__bin__factorial.rs_line_8_001.log",
"src__bin__factorial.rs_line_2_col_5.log",
"src__bin__factorial.rs_line_8_col_5.log",
"src__bin__factorial.rs_line_8_col_5_001.log",
]

0 comments on commit 84449a4

Please sign in to comment.