From 3904d5b6147980fb28b6f6913112b110c948d531 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 3 Jun 2025 16:12:52 +0200 Subject: [PATCH] uptime: move imports into test function to simplify the cfg handling --- tests/by-util/test_uptime.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index 7ec71ceba..fb625bd62 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -8,21 +8,10 @@ #[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))] use uutests::at_and_ucmd; -use uutests::new_ucmd; use uutests::util::TestScenario; -use uutests::util_name; +use uutests::{new_ucmd, util_name}; -#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_env = "musl")))] -use bincode::{config, serde::encode_to_vec}; use regex::Regex; -#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_env = "musl")))] -use serde::Serialize; -#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_env = "musl")))] -use serde_big_array::BigArray; -#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_env = "musl")))] -use std::fs::File; -#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_env = "musl")))] -use std::{io::Write, path::PathBuf}; #[test] fn test_invalid_arg() { @@ -110,6 +99,12 @@ fn test_uptime_with_non_existent_file() { )] #[allow(clippy::too_many_lines, clippy::items_after_statements)] fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { + use bincode::{config, serde::encode_to_vec}; + use serde::Serialize; + use serde_big_array::BigArray; + use std::fs::File; + use std::{io::Write, path::PathBuf}; + // This test will pass for freebsd but we currently don't support changing the utmpx file for // freebsd. let ts = TestScenario::new(util_name!());