Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ nix = { workspace = true, features = [
"poll",
] }
xattr = { workspace = true, optional = true }
itertools = { workspace = true, optional = true }

[dev-dependencies]
tempfile = { workspace = true }
Expand Down Expand Up @@ -186,4 +187,4 @@ wide = []
tty = []
time = ["jiff"]
uptime = ["jiff", "libc", "windows-sys", "utmpx", "utmp-classic"]
benchmark = ["divan", "tempfile"]
benchmark = ["divan", "itertools", "tempfile"]
7 changes: 5 additions & 2 deletions src/uucore/src/lib/features/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf};

use itertools::Itertools as _;

/// Create a temporary file with test data
pub fn create_test_file(data: &[u8], temp_dir: &Path) -> PathBuf {
let file_path = temp_dir.join("test_data.txt");
Expand All @@ -32,8 +34,9 @@ where
F: FnOnce(std::vec::IntoIter<std::ffi::OsString>) -> i32,
{
// Prepend a dummy program name as argv[0] since clap expects it
let mut os_args: Vec<std::ffi::OsString> = vec!["benchmark".into()];
os_args.extend(args.iter().map(|s| (*s).into()));
let os_args = std::iter::once("benchmark".into())
.chain(args.iter().map(Into::into))
.collect_vec();
util_func(os_args.into_iter())
}

Expand Down
Loading