1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

true,false: remove newline from version string

This commit is contained in:
Daniel Hofstetter 2025-03-14 09:21:37 +01:00
parent 6cf1374b60
commit 10fc96a78b
4 changed files with 14 additions and 7 deletions

View file

@ -28,7 +28,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let error = match e.kind() { let error = match e.kind() {
clap::error::ErrorKind::DisplayHelp => command.print_help(), clap::error::ErrorKind::DisplayHelp => command.print_help(),
clap::error::ErrorKind::DisplayVersion => { clap::error::ErrorKind::DisplayVersion => {
writeln!(std::io::stdout(), "{}", command.render_version()) write!(std::io::stdout(), "{}", command.render_version())
} }
_ => Ok(()), _ => Ok(()),
}; };

View file

@ -22,7 +22,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let error = match e.kind() { let error = match e.kind() {
clap::error::ErrorKind::DisplayHelp => command.print_help(), clap::error::ErrorKind::DisplayHelp => command.print_help(),
clap::error::ErrorKind::DisplayVersion => { clap::error::ErrorKind::DisplayVersion => {
writeln!(std::io::stdout(), "{}", command.render_version()) write!(std::io::stdout(), "{}", command.render_version())
} }
_ => Ok(()), _ => Ok(()),
}; };

View file

@ -2,7 +2,10 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
use regex::Regex;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
use std::fs::OpenOptions; use std::fs::OpenOptions;
@ -13,10 +16,9 @@ fn test_no_args() {
#[test] #[test]
fn test_version() { fn test_version() {
new_ucmd!() let re = Regex::new(r"^false .*\d+\.\d+\.\d+\n$").unwrap();
.args(&["--version"])
.fails() new_ucmd!().args(&["--version"]).fails().stdout_matches(&re);
.stdout_contains("false");
} }
#[test] #[test]

View file

@ -2,7 +2,10 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
use regex::Regex;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
use std::fs::OpenOptions; use std::fs::OpenOptions;
@ -13,10 +16,12 @@ fn test_no_args() {
#[test] #[test]
fn test_version() { fn test_version() {
let re = Regex::new(r"^true .*\d+\.\d+\.\d+\n$").unwrap();
new_ucmd!() new_ucmd!()
.args(&["--version"]) .args(&["--version"])
.succeeds() .succeeds()
.stdout_contains("true"); .stdout_matches(&re);
} }
#[test] #[test]