@@ -31,6 +31,8 @@ pub struct Config {
3131 pub cfgs : CommandBuilder ,
3232 /// What to do in case the stdout/stderr output differs from the expected one.
3333 pub output_conflict_handling : OutputConflictHandling ,
34+ /// The recommended command to bless failing tests.
35+ pub bless_command : Option < String > ,
3436 /// Path to a `Cargo.toml` that describes which dependencies the tests can access.
3537 pub dependencies_crate_manifest_path : Option < PathBuf > ,
3638 /// The command to run can be changed from `cargo` to any custom command to build the
@@ -85,6 +87,7 @@ impl Config {
8587 program : CommandBuilder :: rustc ( ) ,
8688 cfgs : CommandBuilder :: cfgs ( ) ,
8789 output_conflict_handling : OutputConflictHandling :: Bless ,
90+ bless_command : None ,
8891 dependencies_crate_manifest_path : None ,
8992 dependency_builder : CommandBuilder :: cargo ( ) ,
9093 out_dir : std:: env:: var_os ( "CARGO_TARGET_DIR" )
@@ -118,11 +121,7 @@ impl Config {
118121 }
119122
120123 /// Populate the config with the values from parsed command line arguments.
121- /// If neither `--bless` or `--check` are provided `default_bless` is used.
122- ///
123- /// The default output conflict handling command suggests adding `--bless`
124- /// to the end of the current command.
125- pub fn with_args ( & mut self , args : & Args , default_bless : bool ) {
124+ pub fn with_args ( & mut self , args : & Args ) {
126125 let Args {
127126 ref filters,
128127 check,
@@ -144,22 +143,11 @@ impl Config {
144143
145144 self . list = list;
146145
147- let bless = match ( bless, check) {
148- ( _, true ) => false ,
149- ( true , _) => true ,
150- _ => default_bless,
151- } ;
152- self . output_conflict_handling = if bless {
153- OutputConflictHandling :: Bless
154- } else {
155- OutputConflictHandling :: Error ( format ! (
156- "{} --bless" ,
157- std:: env:: args( )
158- . map( |s| format!( "{s:?}" ) )
159- . collect:: <Vec <_>>( )
160- . join( " " )
161- ) )
162- } ;
146+ if check {
147+ self . output_conflict_handling = OutputConflictHandling :: Error ;
148+ } else if bless {
149+ self . output_conflict_handling = OutputConflictHandling :: Bless ;
150+ }
163151 }
164152
165153 /// Replace all occurrences of a path in stderr/stdout with a byte string.
@@ -289,8 +277,10 @@ impl Config {
289277#[ derive( Debug , Clone ) ]
290278/// The different options for what to do when stdout/stderr files differ from the actual output.
291279pub enum OutputConflictHandling {
292- /// The string should be a command that can be executed to bless all tests.
293- Error ( String ) ,
280+ /// Fail the test when mismatches are found, if provided the command string
281+ /// in [`Config::bless_command`] will be suggested as a way to bless the
282+ /// test.
283+ Error ,
294284 /// Ignore mismatches in the stderr/stdout files.
295285 Ignore ,
296286 /// Instead of erroring if the stderr/stdout differs from the expected
0 commit comments