Skip to content

Commit c202084

Browse files
committed
Broaden args param of configure_command
This makes the private `gix_testtools::configure_command` function generic (in type as well as lifetime) to accept anything as `args` that the `args` method of `std::process::Command` accepts. This also uses the broader parameter type to simplify a test.
1 parent 4f92140 commit c202084

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/tools/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::{
1212
collections::BTreeMap,
1313
env,
14-
ffi::OsString,
14+
ffi::{OsStr, OsString},
1515
io::Read,
1616
path::{Path, PathBuf},
1717
str::FromStr,
@@ -589,11 +589,15 @@ const NULL_DEVICE: &str = "NUL";
589589
#[cfg(not(windows))]
590590
const NULL_DEVICE: &str = "/dev/null";
591591

592-
fn configure_command<'a>(
592+
fn configure_command<'a, I, S>(
593593
cmd: &'a mut std::process::Command,
594-
args: &[String],
594+
args: I,
595595
script_result_directory: &Path,
596-
) -> &'a mut std::process::Command {
596+
) -> &'a mut std::process::Command
597+
where
598+
I: IntoIterator<Item = S>,
599+
S: AsRef<OsStr>,
600+
{
597601
let mut msys_for_git_bash_on_windows = env::var_os("MSYS").unwrap_or_default();
598602
msys_for_git_bash_on_windows.push(" winsymlinks:nativestrict");
599603
cmd.args(args)
@@ -925,10 +929,9 @@ mod tests {
925929
populate_ad_hoc_config_files(temp.path());
926930

927931
let mut cmd = std::process::Command::new("git");
928-
let args = ["config", "-l", "--show-origin"].map(String::from);
929932
cmd.env("GIT_CONFIG_SYSTEM", SCOPE_ENV_VALUE);
930933
cmd.env("GIT_CONFIG_GLOBAL", SCOPE_ENV_VALUE);
931-
configure_command(&mut cmd, &args, temp.path());
934+
configure_command(&mut cmd, ["config", "-l", "--show-origin"], temp.path());
932935

933936
let output = cmd.output().expect("can run git");
934937
let lines: Vec<_> = output

0 commit comments

Comments
 (0)