Skip to content

Commit

Permalink
Add a hint if snapshots might be skipped. Fixes #314
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Dec 11, 2022
1 parent 011365d commit 26a5022
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cargo-insta/src/cli.rs
Expand Up @@ -21,6 +21,9 @@ use crate::cargo::{
};
use crate::utils::{err_msg, QuietExit};

const IGNORE_MESSAGE: &str =
"some paths are ignored, use --no-ignore if you have snapshots in ignored paths.";

/// A helper utility to work with insta snapshots.
#[derive(StructOpt, Debug)]
#[structopt(
Expand Down Expand Up @@ -392,8 +395,13 @@ fn process_snapshots(cmd: ProcessCommand, op: Option<Operation>) -> Result<(), B
if snapshot_count == 0 {
if !cmd.quiet {
println!("{}: no snapshots to review", style("done").bold());
if !loc.no_ignore {
println!("{}: {}", style("warning").yellow().bold(), IGNORE_MESSAGE);
}
}
return Ok(());
} else if !loc.no_ignore {
println!("{}: {}", style("info").bold(), IGNORE_MESSAGE);
}

let mut accepted = vec![];
Expand Down Expand Up @@ -706,10 +714,16 @@ fn test_run(mut cmd: TestCommand, color: &str) -> Result<(), Box<dyn Error>> {
style(snapshot_count).yellow(),
if snapshot_count != 1 { "s" } else { "" }
);
if !loc.no_ignore {
println!(" {}", IGNORE_MESSAGE);
}
eprintln!("use `cargo insta review` to review snapshots");
return Err(QuietExit(1).into());
} else {
println!("{}: no snapshots to review", style("info").bold());
if !loc.no_ignore {
println!("{}: {}", style("warning").yellow().bold(), IGNORE_MESSAGE);
}
}
}

Expand Down

0 comments on commit 26a5022

Please sign in to comment.