diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 3ae25e569..2b6e94549 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -28,7 +28,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let error = match e.kind() { clap::error::ErrorKind::DisplayHelp => command.print_help(), clap::error::ErrorKind::DisplayVersion => { - writeln!(std::io::stdout(), "{}", command.render_version()) + write!(std::io::stdout(), "{}", command.render_version()) } _ => Ok(()), }; diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 637758625..98f4bcac2 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -22,7 +22,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let error = match e.kind() { clap::error::ErrorKind::DisplayHelp => command.print_help(), clap::error::ErrorKind::DisplayVersion => { - writeln!(std::io::stdout(), "{}", command.render_version()) + write!(std::io::stdout(), "{}", command.render_version()) } _ => Ok(()), }; diff --git a/tests/by-util/test_false.rs b/tests/by-util/test_false.rs index b2bae03c0..23b3e914b 100644 --- a/tests/by-util/test_false.rs +++ b/tests/by-util/test_false.rs @@ -2,7 +2,10 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. + use crate::common::util::TestScenario; +use regex::Regex; + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] use std::fs::OpenOptions; @@ -13,10 +16,9 @@ fn test_no_args() { #[test] fn test_version() { - new_ucmd!() - .args(&["--version"]) - .fails() - .stdout_contains("false"); + let re = Regex::new(r"^false .*\d+\.\d+\.\d+\n$").unwrap(); + + new_ucmd!().args(&["--version"]).fails().stdout_matches(&re); } #[test] diff --git a/tests/by-util/test_true.rs b/tests/by-util/test_true.rs index a01a0df6e..7711d9b72 100644 --- a/tests/by-util/test_true.rs +++ b/tests/by-util/test_true.rs @@ -2,7 +2,10 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. + use crate::common::util::TestScenario; +use regex::Regex; + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] use std::fs::OpenOptions; @@ -13,10 +16,12 @@ fn test_no_args() { #[test] fn test_version() { + let re = Regex::new(r"^true .*\d+\.\d+\.\d+\n$").unwrap(); + new_ucmd!() .args(&["--version"]) .succeeds() - .stdout_contains("true"); + .stdout_matches(&re); } #[test]