about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-26 08:22:52 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-07-26 08:22:52 +0000
commit841f8dc19f3e0be4377efdf0fdd35191670308e5 (patch)
tree3c6805dd1d8848b4aa28b84f12a0b9c60daa5b51
parent2b444672e10d1a019c194729b9e4800d39904459 (diff)
downloadrust-841f8dc19f3e0be4377efdf0fdd35191670308e5.tar.gz
rust-841f8dc19f3e0be4377efdf0fdd35191670308e5.zip
Make `x test src/tools/rustfmt --bless` format rustfmt with the freshly built in-tree version
-rw-r--r--src/bootstrap/test.rs4
-rw-r--r--src/tools/rustfmt/src/parse/session.rs16
-rw-r--r--src/tools/rustfmt/src/test/mod.rs6
3 files changed, 17 insertions, 9 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index c69b21488d2..1fe92098fd6 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -430,6 +430,10 @@ impl Step for Rustfmt {
             &[],
         );
 
+        if builder.config.cmd.bless() {
+            cargo.env("BLESS", "1");
+        }
+
         let dir = testdir(builder, compiler.host);
         t!(fs::create_dir_all(&dir));
         cargo.env("RUSTFMT_TEST_DIR", dir);
diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs
index 6ce68c2c2fb..aa75b477473 100644
--- a/src/tools/rustfmt/src/parse/session.rs
+++ b/src/tools/rustfmt/src/parse/session.rs
@@ -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 {
diff --git a/src/tools/rustfmt/src/test/mod.rs b/src/tools/rustfmt/src/test/mod.rs
index cfad4a8ed0e..364aa225f68 100644
--- a/src/tools/rustfmt/src/test/mod.rs
+++ b/src/tools/rustfmt/src/test/mod.rs
@@ -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(),