Skip to content

Commit

Permalink
Add bless env-var to update changed tests automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo157 committed Oct 22, 2023
1 parent 547577f commit 1135e56
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,12 @@ fn handle_result(

// Ignore LF and CRLF difference for Windows.
if !string_eq_ignore_newline_repr(&fmt_text, &text) {
if std::env::var("RUSTFMT_BLESS").ok().as_deref() == Some("1") {
let write_error = format!("couldn't write target {target:?}");
std::fs::write(&target, &fmt_text).expect(&write_error);
continue;
}

let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE);
assert!(
!diff.is_empty(),
Expand Down

0 comments on commit 1135e56

Please sign in to comment.