Skip to content

Commit dcb0721

Browse files
committedJan 20, 2022
Support --bless for pp-exact pretty printer tests
1 parent 237949b commit dcb0721

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)
Please sign in to comment.