Commit graph

21 commits

Author SHA1 Message Date
Miles Liu
f406b56f4a
timeout: fix subprocess is never terminated 2023-03-10 18:08:54 +08:00
Sylvestre Ledru
74419366fd timeout: add a test to verify that it fails as expected
Follow up of PR #4388
2023-02-22 21:25:23 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Terts Diepraam
44ea43f058 tests: remove status_code, which is the same as code_is 2023-01-01 17:25:59 +01:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Terts Diepraam
18369dc0be all: use array intoiterator 2022-04-05 10:39:31 +02:00
Jeffrey Finkelstein
b34685f8a5 timeout: return 125 on invalid time interval args
Exit with status 125 (indicating an error in `timeout` itself) when
the timeout duration is invalid or the "kill after" duration is
invalid.
2022-03-27 11:45:51 +02:00
Jeffrey Finkelstein
c43ef8b704 timeout: support long form of --kill-after arg
Add support for the long form of the `--kill-after`
argument. Previously only the short form `-k` was supported.
2022-03-26 20:20:30 -04:00
Jeffrey Finkelstein
760a15aa74 timeout: produce usage error on invalid signal
Produce a usage error on an invalid signal argument. For example,

    $ timeout --signal=invalid 1 sleep 0
    timeout: 'invalid': invalid signal
    Try 'timeout --help' for more information.
2022-03-23 08:39:55 +01:00
Jeffrey Finkelstein
f4af226820 uucore: error on negative interval in parse_time
Return an error when a negative interval is provided as the argument
to `uucore::parse_time::from_str()`, since a `Duration` should only be
non-negative.
2022-03-21 21:11:31 -04:00
Jeffrey Finkelstein
e849aaf846 timeout: give usage error on invalid time interval 2022-03-20 15:16:03 -04:00
Jeffrey Finkelstein
388cb6c83a uucore: use Duration::saturating_mul in parse_time
Use `Duration::saturating_mul()` to avoid a panic due to overflow in
`uucore::parse_time::from_str()`. This change prevents panic on very
large arguments to timeout and sleep.
2022-03-18 23:15:02 -04:00
Jeffrey Finkelstein
1aa6fd1468 timeout: fix bug in --preserve-status mode
Fix a bug where `timeout --preserve-status` was not correctly
preserving the status code of the child process if it timed out. When
that happens, the status code of the child process is considered to be
the signal number (in this case, `SIGTERM`). The exit status of
`timeout` is then 128 plus the numeric code associated with `SIGTERM`.
2022-03-12 19:53:11 -05:00
Sylvestre Ledru
3955354b3a timeout: add a test for empty arg 2022-03-09 19:45:43 +01:00
Michael Debertol
0f9bc8e974 timeout: disable timeout if it is set to zero 2021-06-10 21:24:43 +02:00
Michael Debertol
8e0ed2d20e timeout: support --verbose 2021-06-10 21:24:43 +02:00
Michael Debertol
c5d7cbda32 timeout: handle arguments for the command to run
To prevent clap from parsing flags for the command to run as flags for
timeout, remove the "args" positional argument, but allow to pass flags
via the "command" positional arg.
2021-06-10 17:03:32 +02:00
Roy Ivy III
4e20dedf58 tests ~ refactor/polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Sylvestre Ledru
2c09556964 rustfmt some tests 2021-03-13 23:30:47 +01:00
Alex Lyon
5431e947bc
uucore: process: fix exit status processing (#1743)
* uucore: process: fix exit status processing

* tests: timeout: check whether subcommand exit codes are returned
2021-02-23 10:21:01 +01:00
Roy Ivy III
1b3bb56e66 tests ~ add missing test_UTIL module files (with 'ToDO' comments)
- common_core utils
- additional 'windows' utils
- additional 'unix' utils
2020-06-02 11:25:09 -05:00