From ad9a87118ccce462e6090e85550975c02a61f364 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 12 May 2025 10:52:13 +0200 Subject: [PATCH 1/2] split: merge imports in test --- tests/by-util/test_split.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 59d70a31f..402bf9901 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -17,9 +17,7 @@ use std::{ }; use uutests::util::{AtPath, TestScenario}; -use uutests::at_and_ucmd; -use uutests::new_ucmd; -use uutests::util_name; +use uutests::{at_and_ucmd, new_ucmd, util_name}; fn random_chars(n: usize) -> String { rng() From 0c53409857ffc153c996af744d3b80089bd4898b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 12 May 2025 10:55:50 +0200 Subject: [PATCH 2/2] split: delegate to avoid code duplication in test --- tests/by-util/test_split.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 402bf9901..84e718abd 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -112,11 +112,7 @@ impl RandomFile { /// Add n lines each of size `RandomFile::LINESIZE` fn add_lines(&mut self, lines: usize) { - let mut n = lines; - while n > 0 { - writeln!(self.inner, "{}", random_chars(Self::LINESIZE)).unwrap(); - n -= 1; - } + self.add_lines_with_line_size(lines, Self::LINESIZE); } /// Add n lines each of the given size.