Skip to content

Commit 1135e56

Browse files
committed
Add bless env-var to update changed tests automatically
1 parent 547577f commit 1135e56

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,12 @@ fn handle_result(
834834

835835
// Ignore LF and CRLF difference for Windows.
836836
if !string_eq_ignore_newline_repr(&fmt_text, &text) {
837+
if std::env::var("RUSTFMT_BLESS").ok().as_deref() == Some("1") {
838+
let write_error = format!("couldn't write target {target:?}");
839+
std::fs::write(&target, &fmt_text).expect(&write_error);
840+
continue;
841+
}
842+
837843
let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE);
838844
assert!(
839845
!diff.is_empty(),

0 commit comments

Comments
 (0)