1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #2710 from jfinkels/tests-add-missing-assert-placeholder

tests: add template string to assert! statements
This commit is contained in:
Sylvestre Ledru 2021-10-19 20:53:35 +02:00 committed by GitHub
commit c43436d50a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -907,7 +907,7 @@ impl UCommand {
/// Add a parameter to the invocation. Path arguments are treated relative
/// to the test environment directory.
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut UCommand {
assert!(!self.has_run, ALREADY_RUN);
assert!(!self.has_run, "{}", ALREADY_RUN);
self.comm_string.push(' ');
self.comm_string
.push_str(arg.as_ref().to_str().unwrap_or_default());
@ -918,7 +918,7 @@ impl UCommand {
/// Add multiple parameters to the invocation. Path arguments are treated relative
/// to the test environment directory.
pub fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut UCommand {
assert!(!self.has_run, MULTIPLE_STDIN_MEANINGLESS);
assert!(!self.has_run, "{}", MULTIPLE_STDIN_MEANINGLESS);
let strings = args
.iter()
.map(|s| s.as_ref().to_os_string())
@ -936,7 +936,11 @@ impl UCommand {
/// provides standard input to feed in to the command when spawned
pub fn pipe_in<T: Into<Vec<u8>>>(&mut self, input: T) -> &mut UCommand {
assert!(!self.bytes_into_stdin.is_some(), MULTIPLE_STDIN_MEANINGLESS);
assert!(
!self.bytes_into_stdin.is_some(),
"{}",
MULTIPLE_STDIN_MEANINGLESS
);
self.bytes_into_stdin = Some(input.into());
self
}
@ -951,7 +955,7 @@ impl UCommand {
/// This is typically useful to test non-standard workflows
/// like feeding something to a command that does not read it
pub fn ignore_stdin_write_error(&mut self) -> &mut UCommand {
assert!(!self.bytes_into_stdin.is_none(), NO_STDIN_MEANINGLESS);
assert!(!self.bytes_into_stdin.is_none(), "{}", NO_STDIN_MEANINGLESS);
self.ignore_stdin_write_error = true;
self
}
@ -961,7 +965,7 @@ impl UCommand {
K: AsRef<OsStr>,
V: AsRef<OsStr>,
{
assert!(!self.has_run, ALREADY_RUN);
assert!(!self.has_run, "{}", ALREADY_RUN);
self.raw.env(key, val);
self
}
@ -980,7 +984,7 @@ impl UCommand {
/// Spawns the command, feeds the stdin if any, and returns the
/// child process immediately.
pub fn run_no_wait(&mut self) -> Child {
assert!(!self.has_run, ALREADY_RUN);
assert!(!self.has_run, "{}", ALREADY_RUN);
self.has_run = true;
log_info("run", &self.comm_string);
let mut child = self