Skip to content

Commit fbd4908

Browse files
committed
Start testing how the MSYS env var is customized
1 parent d69c617 commit fbd4908

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/tools/src/lib.rs

+41
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ impl<'a> Drop for Env<'a> {
872872
#[cfg(test)]
873873
mod tests {
874874
use super::*;
875+
use std::ffi::OsStr;
875876

876877
#[test]
877878
fn parse_version() {
@@ -932,4 +933,44 @@ mod tests {
932933
assert_eq!(lines, Vec::<&str>::new(), "should be no config variables from files");
933934
assert_eq!(status, 0, "reading the config should succeed");
934935
}
936+
937+
#[test]
938+
fn configure_command_msys() {
939+
let temp = tempfile::TempDir::new().expect("can create temp dir");
940+
let mut cmd = std::process::Command::new("not-actually-run");
941+
942+
let msys_option = configure_command(&mut cmd, &[], temp.path())
943+
.get_envs()
944+
.find(|(k, _)| *k == OsStr::new("MSYS"))
945+
.expect("should customize MSYS variable")
946+
.1
947+
.expect("should set, not unset, MSYS variable")
948+
.to_str()
949+
.expect("valid UTF-8")
950+
.trim_matches(' ');
951+
952+
assert_eq!(msys_option, "winsymlinks:nativestrict");
953+
}
954+
955+
#[test]
956+
fn configure_command_msys_extends() {
957+
let old_msys = r"error_start:C:\gdb.exe";
958+
let temp = tempfile::TempDir::new().expect("can create temp dir");
959+
let mut cmd = std::process::Command::new("not-actually-run");
960+
cmd.env("MSYS", old_msys);
961+
962+
let msys_options = configure_command(&mut cmd, &[], temp.path())
963+
.get_envs()
964+
.find(|(k, _)| *k == OsStr::new("MSYS"))
965+
.expect("should customize MSYS variable")
966+
.1
967+
.expect("should set, not unset, MSYS variable")
968+
.to_str()
969+
.expect("valid UTF-8")
970+
.split(' ') // Just spaces, not arbitrary whitespace.
971+
.filter(|s| !s.is_empty())
972+
.collect::<Vec<_>>();
973+
974+
assert_eq!(msys_options, vec![old_msys, "winsymlinks:nativestrict"]);
975+
}
935976
}

0 commit comments

Comments
 (0)