mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Merge pull request #7446 from cakebaker/true_false_remove_newline_in_version_string
true,false: remove unnecessary newline from version string
This commit is contained in:
commit
4ba518d43b
4 changed files with 22 additions and 15 deletions
|
@ -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(()),
|
||||||
};
|
};
|
||||||
|
|
|
@ -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(()),
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,21 +2,23 @@
|
||||||
//
|
//
|
||||||
// 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;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_exit_code() {
|
fn test_no_args() {
|
||||||
new_ucmd!().fails();
|
new_ucmd!().fails().no_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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]
|
||||||
|
@ -30,7 +32,7 @@ fn test_help() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_short_options() {
|
fn test_short_options() {
|
||||||
for option in ["-h", "-V"] {
|
for option in ["-h", "-V"] {
|
||||||
new_ucmd!().arg(option).fails().stdout_is("");
|
new_ucmd!().arg(option).fails().no_output();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ fn test_conflict() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--help", "--version"])
|
.args(&["--help", "--version"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("");
|
.no_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -2,21 +2,26 @@
|
||||||
//
|
//
|
||||||
// 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;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_exit_code() {
|
fn test_no_args() {
|
||||||
new_ucmd!().succeeds();
|
new_ucmd!().succeeds().no_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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]
|
||||||
|
@ -30,7 +35,7 @@ fn test_help() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_short_options() {
|
fn test_short_options() {
|
||||||
for option in ["-h", "-V"] {
|
for option in ["-h", "-V"] {
|
||||||
new_ucmd!().arg(option).succeeds().stdout_is("");
|
new_ucmd!().arg(option).succeeds().no_output();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ fn test_conflict() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--help", "--version"])
|
.args(&["--help", "--version"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("");
|
.no_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue