mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 06:42:42 +00:00
23a544c485
This avoids hacking around the short options of these command line arguments that have been introduced by clap. Additionally, we test and correctly handle the combination of both version and help. The GNU binary will ignore both arguments in this case while clap would perform the first one. A test for this edge case was added.
53 lines
1.1 KiB
Rust
53 lines
1.1 KiB
Rust
use crate::common::util::*;
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
|
use std::fs::OpenOptions;
|
|
|
|
#[test]
|
|
fn test_exit_code() {
|
|
new_ucmd!().succeeds();
|
|
}
|
|
|
|
#[test]
|
|
fn test_version() {
|
|
new_ucmd!()
|
|
.args(&["--version"])
|
|
.succeeds()
|
|
.stdout_contains("true");
|
|
}
|
|
|
|
#[test]
|
|
fn test_help() {
|
|
new_ucmd!()
|
|
.args(&["--help"])
|
|
.succeeds()
|
|
.stdout_contains("true");
|
|
}
|
|
|
|
#[test]
|
|
fn test_short_options() {
|
|
for option in ["-h", "-V"] {
|
|
new_ucmd!().arg(option).succeeds().stdout_is("");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_conflict() {
|
|
new_ucmd!()
|
|
.args(&["--help", "--version"])
|
|
.succeeds()
|
|
.stdout_is("");
|
|
}
|
|
|
|
#[test]
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
|
fn test_full() {
|
|
for option in ["--version", "--help"] {
|
|
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
|
|
|
|
new_ucmd!()
|
|
.arg(option)
|
|
.set_stdout(dev_full)
|
|
.fails()
|
|
.stderr_contains("No space left on device");
|
|
}
|
|
}
|