Skip to content

Commit

Permalink
Keep environment variables in a BTreeMap to preserve sort order
Browse files Browse the repository at this point in the history
This prevents verbose output from varying between runs due to HashMap
(non-)ordering.
  • Loading branch information
joshtriplett committed Feb 10, 2020
1 parent 3c53211 commit e84a4ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cargo/util/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::util::{process_error, read2, CargoResult, CargoResultExt};
use anyhow::bail;
use jobserver::Client;
use shell_escape::escape;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::env;
use std::ffi::{OsStr, OsString};
use std::fmt;
Expand All @@ -17,7 +17,7 @@ pub struct ProcessBuilder {
/// A list of arguments to pass to the program.
args: Vec<OsString>,
/// Any environment variables that should be set for the program.
env: HashMap<String, Option<OsString>>,
env: BTreeMap<String, Option<OsString>>,
/// The directory to run the program from.
cwd: Option<OsString>,
/// The `make` jobserver. See the [jobserver crate][jobserver_docs] for
Expand Down Expand Up @@ -128,7 +128,7 @@ impl ProcessBuilder {

/// Gets all environment variables explicitly set or unset for the process (not inherited
/// vars).
pub fn get_envs(&self) -> &HashMap<String, Option<OsString>> {
pub fn get_envs(&self) -> &BTreeMap<String, Option<OsString>> {
&self.env
}

Expand Down Expand Up @@ -334,7 +334,7 @@ pub fn process<T: AsRef<OsStr>>(cmd: T) -> ProcessBuilder {
program: cmd.as_ref().to_os_string(),
args: Vec::new(),
cwd: None,
env: HashMap::new(),
env: BTreeMap::new(),
jobserver: None,
display_env_vars: false,
}
Expand Down

0 comments on commit e84a4ed

Please sign in to comment.