Skip to content

Commit

Permalink
Remove configure_command_msys* tests at least for now
Browse files Browse the repository at this point in the history
Because they are not really testing the right thing, due to the
distinction between inherited and `.env()`-specified environment.

See #1578.

While for `configure_command_clears_external_config` this slightly
diminishes but largely leaves intact the value of the test, the
`configure_command_msys` and `configure_command_msys_extends` tests
are really verifying almost nothing, and the latter (for this
reason) cannot pass.

A variant of it for testing the preceding fix to append to
arbitrary environment variable values would likewise not be able to
pass. So that is not added at this time.

Because the `configure_command_clears_external_config` test remains
useful, it is not removed.
  • Loading branch information
EliahKagan committed Sep 6, 2024
1 parent 8dc5d7a commit c38d9b9
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@ impl<'a> Drop for Env<'a> {
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::OsStr;

#[test]
fn parse_version() {
Expand Down Expand Up @@ -933,44 +932,4 @@ mod tests {
assert_eq!(lines, Vec::<&str>::new(), "should be no config variables from files");
assert_eq!(status, 0, "reading the config should succeed");
}

#[test]
fn configure_command_msys() {
let temp = tempfile::TempDir::new().expect("can create temp dir");
let mut cmd = std::process::Command::new("not-actually-run");

let msys_option = configure_command(&mut cmd, &[], temp.path())
.get_envs()
.find(|(k, _)| *k == OsStr::new("MSYS"))
.expect("should customize MSYS variable")
.1
.expect("should set, not unset, MSYS variable")
.to_str()
.expect("valid UTF-8")
.trim_matches(' ');

assert_eq!(msys_option, "winsymlinks:nativestrict");
}

#[test]
fn configure_command_msys_extends() {
let old_msys = r"error_start:C:\gdb.exe";
let temp = tempfile::TempDir::new().expect("can create temp dir");
let mut cmd = std::process::Command::new("not-actually-run");
cmd.env("MSYS", old_msys);

let msys_options = configure_command(&mut cmd, &[], temp.path())
.get_envs()
.find(|(k, _)| *k == OsStr::new("MSYS"))
.expect("should customize MSYS variable")
.1
.expect("should set, not unset, MSYS variable")
.to_str()
.expect("valid UTF-8")
.split(' ') // Just spaces, not arbitrary whitespace.
.filter(|s| !s.is_empty())
.collect::<Vec<_>>();

assert_eq!(msys_options, vec![old_msys, "winsymlinks:nativestrict"]);
}
}

0 comments on commit c38d9b9

Please sign in to comment.