Skip to content

Commit 50a8838

Browse files
committed
text emitter: use singular form when there was only 1 unmatched diagnostic
1 parent cf1e1d0 commit 50a8838

File tree

5 files changed

+393
-45
lines changed

5 files changed

+393
-45
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Fixed
1414

15+
- the text output now uses the singular form when there was 1 unmatched diagnostic
16+
1517
### Changed
1618

1719
- DependencyBuilder: if `config.target` is set (which is always the case if you use `run_tests_generic`),

src/status_emitter/text.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crossbeam_channel::{Sender, TryRecvError};
1919
#[cfg(feature = "indicatif")]
2020
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
2121
use spanned::Span;
22+
use std::borrow::Cow;
2223
use std::fmt::{Debug, Display};
2324
use std::io::Write as _;
2425
use std::path::Path;
@@ -765,19 +766,25 @@ fn print_error(error: &Error, path: &Path) {
765766
})
766767
.collect::<Vec<_>>();
767768
// This will print a suitable error header.
769+
770+
let error_msg: Cow<str> = match msgs.len() {
771+
1 => "there was 1 unmatched diagnostic".into(),
772+
n => format!("there were {n} unmatched diagnostics").into(),
773+
};
768774
create_error(
769-
format!("there were {} unmatched diagnostics", msgs.len()),
775+
error_msg,
770776
&[&msgs
771777
.iter()
772778
.map(|(msg, lc)| (msg.as_ref(), lc.clone()))
773779
.collect::<Vec<_>>()],
774780
path,
775781
);
776782
} else {
777-
print_error_header(format_args!(
778-
"there were {} unmatched diagnostics that occurred outside the testfile and had no pattern",
779-
msgs.len(),
780-
));
783+
let error_msg: Cow<str> = match msgs.len() {
784+
1 => "there was 1 unmatched diagnostic that occurred outside the testfile and had no pattern".into(),
785+
n => format!("there were {n} unmatched diagnostics that occurred outside the testfile and had no pattern").into(),
786+
};
787+
print_error_header(error_msg);
781788
for Message {
782789
level,
783790
message,

0 commit comments

Comments
 (0)