Skip to content
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

Add RUSTUP_TOOLCHAIN_DIR #3207

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ impl<'a> InstalledCommonToolchain<'a> {

cmd.env("RUSTUP_TOOLCHAIN", &self.0.name);
cmd.env("RUSTUP_HOME", &self.0.cfg.rustup_dir);
cmd.env("RUSTUP_TOOLCHAIN_DIR", &self.0.path);
}

fn set_ldpath(&self, cmd: &mut Command) {
Expand Down
18 changes: 17 additions & 1 deletion tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod mock;

use std::env::consts::EXE_SUFFIX;
use std::fs;
use std::path::{PathBuf, MAIN_SEPARATOR};
use std::path::{Path, PathBuf, MAIN_SEPARATOR};

use rustup::for_host;
use rustup::test::this_host_triple;
Expand Down Expand Up @@ -2252,3 +2252,19 @@ fn warn_on_duplicate_rust_toolchain_file() {
);
});
}

/// Checks that the RUSTUP_TOOLCHAIN_DIR is set.
#[test]
fn toolchain_dir_env() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "nightly"]);
let output = clitools::run(config, "rustup", &["which", "rustc"], &[]);
let real_mock_rustc = Path::new(output.stdout.trim());
let toolchain_dir = real_mock_rustc.parent().unwrap().parent().unwrap();
expect_stderr_ok(
config,
&["rustc", "--echo-env", "RUSTUP_TOOLCHAIN_DIR"],
toolchain_dir.to_str().unwrap(),
);
});
}
5 changes: 5 additions & 0 deletions tests/mock/mock_bin_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ fn main() {
let mut out = io::stderr();
writeln!(out, "{}", std::env::var("PATH").unwrap()).unwrap();
}
Some("--echo-env") => {
let mut out = io::stderr();
let var = args.next().unwrap();
writeln!(out, "{}", std::env::var(var).unwrap_or_default()).unwrap();
}
_ => panic!("bad mock proxy commandline"),
}
}
Expand Down