History

Start testing how the MSYS env var is customized

Eliah Kagan committed 2 years ago

Commit fbd49081 parent d69c6171 file · +41 −0Browse files

Unified · Split

tests/tools/src/lib.rs+41−0
@@ -872,6 +872,7 @@ impl<'a> Drop for Env<'a> { · 871 unmodified lines
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 { · 54 unmodified lines
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 }