Skip to content

Commit 841f8dc

Browse files
committed
Make x test src/tools/rustfmt --bless format rustfmt with the freshly built in-tree version
1 parent 2b44467 commit 841f8dc

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/bootstrap/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ impl Step for Rustfmt {
430430
&[],
431431
);
432432

433+
if builder.config.cmd.bless() {
434+
cargo.env("BLESS", "1");
435+
}
436+
433437
let dir = testdir(builder, compiler.host);
434438
t!(fs::create_dir_all(&dir));
435439
cargo.env("RUSTFMT_TEST_DIR", dir);

src/tools/rustfmt/src/parse/session.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,13 @@ fn default_handler(
152152
TerminalUrl::No,
153153
))
154154
};
155-
Handler::with_emitter(
156-
Box::new(SilentOnIgnoredFilesEmitter {
157-
has_non_ignorable_parser_errors: false,
158-
source_map,
159-
emitter,
160-
ignore_path_set,
161-
can_reset,
162-
}),
163-
)
155+
Handler::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
156+
has_non_ignorable_parser_errors: false,
157+
source_map,
158+
emitter,
159+
ignore_path_set,
160+
can_reset,
161+
}))
164162
}
165163

166164
impl ParseSess {

src/tools/rustfmt/src/test/mod.rs

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

839839
// Ignore LF and CRLF difference for Windows.
840840
if !string_eq_ignore_newline_repr(&fmt_text, &text) {
841+
if let Some(bless) = std::env::var_os("BLESS") {
842+
if bless != "0" {
843+
std::fs::write(file_name, fmt_text).unwrap();
844+
continue;
845+
}
846+
}
841847
let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE);
842848
assert!(
843849
!diff.is_empty(),

0 commit comments

Comments
 (0)