Skip to content

Commit 91791ea

Browse files
committed
tests: verify --help/--version exit codes on /dev/full, csplit empty pattern
1 parent bf49ce9 commit 91791ea

7 files changed

Lines changed: 78 additions & 0 deletions

File tree

tests/by-util/test_csplit.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,11 @@ fn test_write_error_dev_full_keep_files() {
15831583
assert!(at.file_exists("xx00"));
15841584
assert_eq!(at.read("xx00"), "1\n");
15851585
}
1586+
1587+
#[test]
1588+
fn test_empty_regex_pattern() {
1589+
// '//' uses the empty regex (matches beginning of each line)
1590+
let (at, mut ucmd) = at_and_ucmd!();
1591+
at.write("input", "hello\nworld\n");
1592+
ucmd.args(&["input", "//"]).succeeds();
1593+
}

tests/by-util/test_env.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,3 +2009,17 @@ fn test_ignore_signal_pipe_broken_pipe_regression() {
20092009
"With --ignore-signal=PIPE, process should exit gracefully (0 or 1), got: {ignore_signal_exit_code}"
20102010
);
20112011
}
2012+
2013+
#[test]
2014+
#[cfg(target_os = "linux")]
2015+
fn test_help_version_dev_full_exit_code() {
2016+
use std::fs::OpenOptions;
2017+
use uutests::new_ucmd;
2018+
for arg in ["--help", "--version"] {
2019+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2020+
new_ucmd!()
2021+
.arg(arg)
2022+
.set_stdout(dev_full)
2023+
.fails_with_code(125);
2024+
}
2025+
}

tests/by-util/test_expr.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,3 +1975,14 @@ fn test_emoji_operations() {
19751975
.succeeds()
19761976
.stdout_only("1\n");
19771977
}
1978+
1979+
#[test]
1980+
#[cfg(target_os = "linux")]
1981+
fn test_help_version_dev_full_exit_code() {
1982+
use std::fs::OpenOptions;
1983+
use uutests::new_ucmd;
1984+
for arg in ["--help", "--version"] {
1985+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
1986+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(3);
1987+
}
1988+
}

tests/by-util/test_ls.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7119,3 +7119,14 @@ fn test_ls_non_utf8_hidden() {
71197119

71207120
scene.ucmd().succeeds().stdout_does_not_contain(".hidden");
71217121
}
7122+
7123+
#[test]
7124+
#[cfg(target_os = "linux")]
7125+
fn test_help_version_dev_full_exit_code() {
7126+
use std::fs::OpenOptions;
7127+
use uutests::new_ucmd;
7128+
for arg in ["--help", "--version"] {
7129+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
7130+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(2);
7131+
}
7132+
}

tests/by-util/test_sort.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,3 +2766,14 @@ e f 5436 down data path1 path2 path3 path4 path5\n";
27662766
}
27672767

27682768
/* spell-checker: enable */
2769+
2770+
#[test]
2771+
#[cfg(target_os = "linux")]
2772+
fn test_help_version_dev_full_exit_code() {
2773+
use std::fs::OpenOptions;
2774+
use uutests::new_ucmd;
2775+
for arg in ["--help", "--version"] {
2776+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2777+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(2);
2778+
}
2779+
}

tests/by-util/test_test.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,3 +1073,16 @@ fn test_unary_op_as_literal_in_three_arg_form() {
10731073
new_ucmd!().args(&["-f", "=", "a"]).fails_with_code(1);
10741074
new_ucmd!().args(&["-f", "=", "a", "-o", "b"]).succeeds();
10751075
}
1076+
1077+
#[test]
1078+
#[cfg(target_os = "linux")]
1079+
fn test_lbracket_help_dev_full_exit_code() {
1080+
use std::fs::OpenOptions;
1081+
use uutests::util::TestScenario;
1082+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
1083+
TestScenario::new("[")
1084+
.ucmd()
1085+
.arg("--help")
1086+
.set_stdout(dev_full)
1087+
.fails_with_code(2);
1088+
}

tests/by-util/test_tty.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,13 @@ fn test_version_pipe_no_stderr() {
9595
child.close_stdout();
9696
child.wait().unwrap().no_stderr();
9797
}
98+
99+
#[test]
100+
#[cfg(target_os = "linux")]
101+
fn test_help_version_dev_full_exit_code() {
102+
use std::fs::OpenOptions;
103+
for arg in ["--help", "--version"] {
104+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
105+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(3);
106+
}
107+
}

0 commit comments

Comments
 (0)