mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
kill: test "-l <number>" & adapt error messages
This commit is contained in:
parent
b4487229b9
commit
cdc8d5f627
2 changed files with 28 additions and 8 deletions
|
@ -193,7 +193,7 @@ fn print_signal(signal_name_or_value: &str) -> UResult<()> {
|
||||||
}
|
}
|
||||||
Err(USimpleError::new(
|
Err(USimpleError::new(
|
||||||
1,
|
1,
|
||||||
format!("unknown signal name {}", signal_name_or_value.quote()),
|
format!("{}: invalid signal", signal_name_or_value.quote()),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ fn parse_signal_value(signal_name: &str) -> UResult<usize> {
|
||||||
Some(x) => Ok(x),
|
Some(x) => Ok(x),
|
||||||
None => Err(USimpleError::new(
|
None => Err(USimpleError::new(
|
||||||
1,
|
1,
|
||||||
format!("unknown signal name {}", signal_name.quote()),
|
format!("{}: invalid signal", signal_name.quote()),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
//
|
//
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
|
// spell-checker:ignore IAMNOTASIGNAL
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use crate::common::util::TestScenario;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
|
@ -108,6 +111,24 @@ fn test_kill_table_lists_all_vertically() {
|
||||||
assert!(signals.contains(&"EXIT"));
|
assert!(signals.contains(&"EXIT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_list_one_signal_from_number() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-l")
|
||||||
|
.arg("9")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_only("KILL\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_kill_list_one_signal_from_invalid_number() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-l")
|
||||||
|
.arg("99")
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("'99': invalid signal");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_kill_list_one_signal_from_name() {
|
fn test_kill_list_one_signal_from_name() {
|
||||||
// Use SIGKILL because it is 9 on all unixes.
|
// Use SIGKILL because it is 9 on all unixes.
|
||||||
|
@ -162,11 +183,11 @@ fn test_kill_list_two_signal_from_name() {
|
||||||
fn test_kill_list_three_signal_first_unknown() {
|
fn test_kill_list_three_signal_first_unknown() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
.arg("IAMNOTASIGNAL") // spell-checker:disable-line
|
.arg("IAMNOTASIGNAL")
|
||||||
.arg("INT")
|
.arg("INT")
|
||||||
.arg("KILL")
|
.arg("KILL")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("unknown signal")
|
.stderr_contains("'IAMNOTASIGNAL': invalid signal")
|
||||||
.stdout_matches(&Regex::new("\\d\n\\d").unwrap());
|
.stdout_matches(&Regex::new("\\d\n\\d").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,9 +195,9 @@ fn test_kill_list_three_signal_first_unknown() {
|
||||||
fn test_kill_set_bad_signal_name() {
|
fn test_kill_set_bad_signal_name() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-s")
|
.arg("-s")
|
||||||
.arg("IAMNOTASIGNAL") // spell-checker:disable-line
|
.arg("IAMNOTASIGNAL")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("unknown signal");
|
.stderr_contains("'IAMNOTASIGNAL': invalid signal");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -291,8 +312,7 @@ fn test_kill_with_signal_name_new_form_unknown_must_match_input_case() {
|
||||||
.arg("IaMnOtAsIgNaL")
|
.arg("IaMnOtAsIgNaL")
|
||||||
.arg(format!("{}", target.pid()))
|
.arg(format!("{}", target.pid()))
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("unknown signal")
|
.stderr_contains("'IaMnOtAsIgNaL': invalid signal");
|
||||||
.stderr_contains("IaMnOtAsIgNaL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue