From 5dc7b3d3f6486cde1429c00a47bb51336c1462bc Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 19 Sep 2025 17:13:43 +0200 Subject: [PATCH 1/2] pinky: move unit test away from integration tests --- src/uu/pinky/src/pinky.rs | 13 +++++++++++++ tests/by-util/test_pinky.rs | 11 ++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 1ba9d5a5109..17be02c459a 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -135,3 +135,16 @@ impl Capitalize for str { }) } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_capitalize() { + assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line + assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line + assert_eq!("", "".capitalize()); + } +} diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index 8a58c3f1ea3..79068327d82 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -3,7 +3,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use pinky::Capitalize; #[cfg(not(target_os = "openbsd"))] use uucore::entries::{Locate, Passwd}; use uutests::new_ucmd; @@ -19,17 +18,11 @@ fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails_with_code(1); } -#[test] -fn test_capitalize() { - assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line - assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line - assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line - assert_eq!("", "".capitalize()); -} - #[test] #[cfg(not(target_os = "openbsd"))] fn test_long_format() { + use pinky::Capitalize; + let login = "root"; let pw: Passwd = Passwd::locate(login).unwrap(); let user_info = pw.user_info.unwrap_or_default(); From d2125f5378a5084fe5ec7ec090ae8c4382719500 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 19 Sep 2025 17:26:22 +0200 Subject: [PATCH 2/2] pinky: cleanup imports in test file --- tests/by-util/test_pinky.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index 79068327d82..977647de8ba 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -5,13 +5,9 @@ #[cfg(not(target_os = "openbsd"))] use uucore::entries::{Locate, Passwd}; -use uutests::new_ucmd; -use uutests::unwrap_or_return; -#[cfg(target_os = "openbsd")] -use uutests::util::TestScenario; #[cfg(not(target_os = "openbsd"))] use uutests::util::{TestScenario, expected_result}; -use uutests::util_name; +use uutests::{new_ucmd, unwrap_or_return, util_name}; #[test] fn test_invalid_arg() {