Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ impl Step for Rustfmt {
&[],
);

if builder.config.cmd.bless() {
cargo.env("BLESS", "1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk - This seems reasonable to me, though I'd like to change the var name to be a little more explicit (perhaps something like RUSTC_BLESS?) so that it's somewhat more explicit especially when working with rustfmt out of tree.

Wanted to make sure you didn't have any objections or alternative naming suggestions before I opened a PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently being worked on in #113298

}

let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
cargo.env("RUSTFMT_TEST_DIR", dir);
Expand Down
16 changes: 7 additions & 9 deletions src/tools/rustfmt/src/parse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,13 @@ fn default_handler(
TerminalUrl::No,
))
};
Handler::with_emitter(
Box::new(SilentOnIgnoredFilesEmitter {
has_non_ignorable_parser_errors: false,
source_map,
emitter,
ignore_path_set,
can_reset,
}),
)
Handler::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
has_non_ignorable_parser_errors: false,
source_map,
emitter,
ignore_path_set,
can_reset,
}))
}

impl ParseSess {
Expand Down
6 changes: 6 additions & 0 deletions src/tools/rustfmt/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,12 @@ fn handle_result(

// Ignore LF and CRLF difference for Windows.
if !string_eq_ignore_newline_repr(&fmt_text, &text) {
if let Some(bless) = std::env::var_os("BLESS") {
if bless != "0" {
std::fs::write(file_name, fmt_text).unwrap();
continue;
}
}
let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE);
assert!(
!diff.is_empty(),
Expand Down