mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #7200 from cakebaker/timeout_add_f_and_p
timeout: add support for `-f` and `-p` short options
This commit is contained in:
commit
704421bd6b
2 changed files with 27 additions and 19 deletions
|
@ -129,6 +129,7 @@ pub fn uu_app() -> Command {
|
|||
.arg(
|
||||
Arg::new(options::FOREGROUND)
|
||||
.long(options::FOREGROUND)
|
||||
.short('f')
|
||||
.help(
|
||||
"when not running timeout directly from a shell prompt, allow \
|
||||
COMMAND to read from the TTY and get TTY signals; in this mode, \
|
||||
|
@ -148,6 +149,7 @@ pub fn uu_app() -> Command {
|
|||
.arg(
|
||||
Arg::new(options::PRESERVE_STATUS)
|
||||
.long(options::PRESERVE_STATUS)
|
||||
.short('p')
|
||||
.help("exit with the same status as COMMAND, even when the command times out")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
|
|
|
@ -65,13 +65,11 @@ fn test_zero_timeout() {
|
|||
new_ucmd!()
|
||||
.args(&["-v", "0", "sleep", ".1"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
.no_output();
|
||||
new_ucmd!()
|
||||
.args(&["-v", "0", "-s0", "-k0", "sleep", ".1"])
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
.no_output();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -82,15 +80,27 @@ fn test_command_empty_args() {
|
|||
.stderr_contains("timeout: empty string");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_foreground() {
|
||||
for arg in ["-f", "--foreground"] {
|
||||
new_ucmd!()
|
||||
.args(&[arg, ".1", "sleep", "10"])
|
||||
.fails()
|
||||
.code_is(124)
|
||||
.no_output();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_preserve_status() {
|
||||
new_ucmd!()
|
||||
.args(&["--preserve-status", ".1", "sleep", "10"])
|
||||
.fails()
|
||||
// 128 + SIGTERM = 128 + 15
|
||||
.code_is(128 + 15)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
for arg in ["-p", "--preserve-status"] {
|
||||
new_ucmd!()
|
||||
.args(&[arg, ".1", "sleep", "10"])
|
||||
.fails()
|
||||
// 128 + SIGTERM = 128 + 15
|
||||
.code_is(128 + 15)
|
||||
.no_output();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -102,8 +112,7 @@ fn test_preserve_status_even_when_send_signal() {
|
|||
.args(&["-s", cont_spelling, "--preserve-status", ".1", "sleep", "2"])
|
||||
.succeeds()
|
||||
.code_is(0)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
.no_output();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,14 +122,12 @@ fn test_dont_overflow() {
|
|||
.args(&["9223372036854775808d", "sleep", "0"])
|
||||
.succeeds()
|
||||
.code_is(0)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
.no_output();
|
||||
new_ucmd!()
|
||||
.args(&["-k", "9223372036854775808d", "10", "sleep", "0"])
|
||||
.succeeds()
|
||||
.code_is(0)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
.no_output();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -153,8 +160,7 @@ fn test_kill_after_long() {
|
|||
new_ucmd!()
|
||||
.args(&["--kill-after=1", "1", "sleep", "0"])
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.no_stderr();
|
||||
.no_output();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue