Skip to content

Commit 6c9d7e4

Browse files
committed
tests: verify --help/--version exit codes on /dev/full, csplit empty pattern
1 parent d5f9293 commit 6c9d7e4

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
@@ -2032,3 +2032,17 @@ fn test_env_disallow_double_underscore_all() {
20322032
.fails()
20332033
.stderr_contains("invalid signal");
20342034
}
2035+
2036+
#[test]
2037+
#[cfg(target_os = "linux")]
2038+
fn test_help_version_dev_full_exit_code() {
2039+
use std::fs::OpenOptions;
2040+
use uutests::new_ucmd;
2041+
for arg in ["--help", "--version"] {
2042+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2043+
new_ucmd!()
2044+
.arg(arg)
2045+
.set_stdout(dev_full)
2046+
.fails_with_code(125);
2047+
}
2048+
}

tests/by-util/test_expr.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,3 +2007,14 @@ fn test_emoji_operations() {
20072007
.succeeds()
20082008
.stdout_only("1\n");
20092009
}
2010+
2011+
#[test]
2012+
#[cfg(target_os = "linux")]
2013+
fn test_help_version_dev_full_exit_code() {
2014+
use std::fs::OpenOptions;
2015+
use uutests::new_ucmd;
2016+
for arg in ["--help", "--version"] {
2017+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2018+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(3);
2019+
}
2020+
}

tests/by-util/test_ls.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7244,3 +7244,14 @@ fn test_ls_a_dotdot_no_error_on_wasi() {
72447244
.stdout_contains("..")
72457245
.no_stderr();
72467246
}
7247+
7248+
#[test]
7249+
#[cfg(target_os = "linux")]
7250+
fn test_help_version_dev_full_exit_code() {
7251+
use std::fs::OpenOptions;
7252+
use uutests::new_ucmd;
7253+
for arg in ["--help", "--version"] {
7254+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
7255+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(2);
7256+
}
7257+
}

tests/by-util/test_sort.rs

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

29632963
/* spell-checker: enable */
2964+
2965+
#[test]
2966+
#[cfg(target_os = "linux")]
2967+
fn test_help_version_dev_full_exit_code() {
2968+
use std::fs::OpenOptions;
2969+
use uutests::new_ucmd;
2970+
for arg in ["--help", "--version"] {
2971+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
2972+
new_ucmd!().arg(arg).set_stdout(dev_full).fails_with_code(2);
2973+
}
2974+
}

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)