Files

65 lines
1.4 KiB
Rust
Raw Permalink Normal View History

2023-08-21 10:49:27 +02:00
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use regex::Regex;
2022-02-01 12:19:00 +01:00
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
use std::fs::OpenOptions;
2025-03-28 09:51:51 +01:00
use uutests::new_ucmd;
2025-07-01 01:52:57 +02:00
#[test]
fn test_no_args() {
2025-03-14 08:57:30 +01:00
new_ucmd!().fails().no_output();
}
2022-02-01 12:19:00 +01:00
#[test]
fn test_version() {
let re = Regex::new(r"^false .*\d+\.\d+\.\d+\n$").unwrap();
new_ucmd!().args(&["--version"]).fails().stdout_matches(&re);
2022-02-01 12:19:00 +01:00
}
#[test]
fn test_help() {
new_ucmd!()
.args(&["--help"])
.fails()
.stdout_contains("false");
}
#[test]
fn test_short_options() {
2022-02-01 14:29:26 +01:00
for option in ["-h", "-V"] {
2025-03-14 08:57:30 +01:00
new_ucmd!().arg(option).fails().no_output();
2022-02-01 12:19:00 +01:00
}
}
2026-02-03 14:44:13 +11:00
#[test]
fn test_extra_args() {
for option in ["--help", "--version"] {
new_ucmd!().args(&[option, "test"]).fails().no_output();
}
}
2022-02-01 14:29:26 +01:00
#[test]
fn test_conflict() {
new_ucmd!()
.args(&["--help", "--version"])
.fails()
2025-03-14 08:57:30 +01:00
.no_output();
2022-02-01 14:29:26 +01:00
}
2022-02-01 12:19:00 +01:00
#[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");
}
}