Skip to content

Commit

Permalink
Rollup merge of #93104 - dtolnay:ppbless, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthiaskrgr committed Jan 20, 2022
2 parents d4ec464 + dcb0721 commit 5e46f7d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5e46f7d

Please sign in to comment.