Skip to content

Commit 3d45a27

Browse files
committed
feat(check): track test additions separately from failures
Tweak the output so those cases are more easily distinguishable, especially the color used by the `+` symbol next to the test name. Exit code is now 2 if all existing tests succeeded, but some were added.
1 parent d8bf218 commit 3d45a27

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/cmd/check.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn check(root: &Path, opts: Opts, cfg: Option<Config>) -> Result<()> {
3434

3535
let total = output.results.len();
3636
let mut failures = 0;
37+
let mut additions = 0;
3738
for (name, res) in output.results {
3839
let new = pending.join(&name);
3940
match res {
@@ -42,24 +43,35 @@ pub fn check(root: &Path, opts: Opts, cfg: Option<Config>) -> Result<()> {
4243
}
4344

4445
TestResult::Failure { snapshot, old } => {
45-
failures += 1;
46-
println!("{} {name}", if old { "✘" } else { "🞥" }.red());
46+
if old {
47+
failures += 1;
48+
println!("{} {name}", "✘".red());
49+
} else {
50+
additions += 1;
51+
println!("{} {name}", "🞥".blue());
52+
}
4753
snapshot.to_writer(File::create(new)?)?;
4854
}
4955
}
5056
}
5157

52-
if failures == 0 {
58+
if failures == 0 && additions == 0 {
5359
if success {
5460
eprintln!("All {total} tests succeeded");
5561
return Ok(());
5662
} else {
5763
break;
5864
}
5965
} else {
60-
eprintln!("{failures} out of {total} tests failed");
66+
if failures != 0 {
67+
let existing = total - additions;
68+
eprintln!("{failures} out of {existing} tests failed");
69+
}
70+
if additions != 0 {
71+
eprintln!("{additions} new tests found");
72+
}
6173
eprintln!("run `namaka review` to review the pending snapshots");
62-
exit(1);
74+
exit(if failures != 0 { 1 } else { 2 });
6375
}
6476
}
6577

0 commit comments

Comments
 (0)