about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2022-01-19 20:12:31 -0800
committerDavid Tolnay <dtolnay@gmail.com>2022-01-19 20:15:08 -0800
commitdcb0721a29f63cd2fb3a30487c81cfb657f0a7ee (patch)
tree0414857bd305fa543b2cf5c6805d08f8266359ad /src
parent237949b6c8e5b387e0a9d1e7a22e0397c95fe488 (diff)
downloadrust-dcb0721a29f63cd2fb3a30487c81cfb657f0a7ee.tar.gz
rust-dcb0721a29f63cd2fb3a30487c81cfb657f0a7ee.zip
Support --bless for pp-exact pretty printer tests
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/runtest.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index f039ba59d23..22785013085 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -500,7 +500,19 @@ impl<'test> TestCx<'test> {
             expected = expected.replace(&cr, "");
         }
 
-        self.compare_source(&expected, &actual);
+        if !self.config.bless {
+            self.compare_source(&expected, &actual);
+        } else if expected != actual {
+            let filepath_buf;
+            let filepath = match &self.props.pp_exact {
+                Some(file) => {
+                    filepath_buf = self.testpaths.file.parent().unwrap().join(file);
+                    &filepath_buf
+                }
+                None => &self.testpaths.file,
+            };
+            fs::write(filepath, &actual).unwrap();
+        }
 
         // If we're only making sure that the output matches then just stop here
         if self.props.pretty_compare_only {