Skip to content

Make configure_command easier to call and comment about MSYS #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2024
Merged
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
12 changes: 7 additions & 5 deletions tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::{
collections::BTreeMap,
env,
ffi::OsString,
ffi::{OsStr, OsString},
io::Read,
path::{Path, PathBuf},
str::FromStr,
Expand Down Expand Up @@ -589,11 +589,14 @@ const NULL_DEVICE: &str = "NUL";
#[cfg(not(windows))]
const NULL_DEVICE: &str = "/dev/null";

fn configure_command<'a>(
fn configure_command<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
cmd: &'a mut std::process::Command,
args: &[String],
args: I,
script_result_directory: &Path,
) -> &'a mut std::process::Command {
// For simplicity, we extend the `MSYS` variable from from our own environment. This disregards
// state from any prior `cmd.env("MSYS")` or `cmd.env_remove("MSYS")` calls. Such calls should
// either be avoided, or made after this function returns (but before spawning the command).
let mut msys_for_git_bash_on_windows = env::var_os("MSYS").unwrap_or_default();
msys_for_git_bash_on_windows.push(" winsymlinks:nativestrict");
cmd.args(args)
Expand Down Expand Up @@ -925,10 +928,9 @@ mod tests {
populate_ad_hoc_config_files(temp.path());

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

let output = cmd.output().expect("can run git");
let lines: Vec<_> = output
Expand Down
Loading