Skip to content

Commit 5e46f7d

Browse files
authored
Rollup merge of #93104 - dtolnay:ppbless, r=Mark-Simulacrum
Support --bless for pp-exact pretty printer tests I ran into this while working on the stack of PRs containing #93102. `x.py test src/test/pretty --bless` previously would `fatal` instead of blessing the input files. Tested by making a silly pretty-printer tweak and running the above command: 98823c3929ebfe796786345c5ee713f63317d9c6
2 parents d4ec464 + dcb0721 commit 5e46f7d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tools/compiletest/src/runtest.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,19 @@ impl<'test> TestCx<'test> {
500500
expected = expected.replace(&cr, "");
501501
}
502502

503-
self.compare_source(&expected, &actual);
503+
if !self.config.bless {
504+
self.compare_source(&expected, &actual);
505+
} else if expected != actual {
506+
let filepath_buf;
507+
let filepath = match &self.props.pp_exact {
508+
Some(file) => {
509+
filepath_buf = self.testpaths.file.parent().unwrap().join(file);
510+
&filepath_buf
511+
}
512+
None => &self.testpaths.file,
513+
};
514+
fs::write(filepath, &actual).unwrap();
515+
}
504516

505517
// If we're only making sure that the output matches then just stop here
506518
if self.props.pretty_compare_only {

0 commit comments

Comments
 (0)