1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Merge pull request #7213 from cakebaker/kill_add_tests

kill: test "-l <number>" & adapt error messages
This commit is contained in:
Sylvestre Ledru 2025-03-07 08:53:35 +01:00 committed by GitHub
commit 0e7a26178f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 8 deletions

View file

@ -2,6 +2,9 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore IAMNOTASIGNAL
use crate::common::util::TestScenario;
use regex::Regex;
use std::os::unix::process::ExitStatusExt;
@ -108,6 +111,24 @@ fn test_kill_table_lists_all_vertically() {
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]
fn test_kill_list_one_signal_from_name() {
// 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() {
new_ucmd!()
.arg("-l")
.arg("IAMNOTASIGNAL") // spell-checker:disable-line
.arg("IAMNOTASIGNAL")
.arg("INT")
.arg("KILL")
.fails()
.stderr_contains("unknown signal")
.stderr_contains("'IAMNOTASIGNAL': invalid signal")
.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() {
new_ucmd!()
.arg("-s")
.arg("IAMNOTASIGNAL") // spell-checker:disable-line
.arg("IAMNOTASIGNAL")
.fails()
.stderr_contains("unknown signal");
.stderr_contains("'IAMNOTASIGNAL': invalid signal");
}
#[test]
@ -291,8 +312,7 @@ fn test_kill_with_signal_name_new_form_unknown_must_match_input_case() {
.arg("IaMnOtAsIgNaL")
.arg(format!("{}", target.pid()))
.fails()
.stderr_contains("unknown signal")
.stderr_contains("IaMnOtAsIgNaL");
.stderr_contains("'IaMnOtAsIgNaL': invalid signal");
}
#[test]