Skip to content

Commit

Permalink
Merge pull request rust-lang#678 from RalfJung/test-env
Browse files Browse the repository at this point in the history
compiletest env var cleanup
  • Loading branch information
RalfJung authored Apr 7, 2019
2 parents 0e4f963 + 336a59d commit 5c5cc2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
20 changes: 1 addition & 19 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@ fn miri_pass(path: &str, target: &str, opt: bool) {
compiletest::run_tests(&config);
}

/// Ensures that the `MIRI_SYSROOT` env var is set.
fn set_sysroot() {
if std::env::var("MIRI_SYSROOT").is_ok() {
// Nothing to do.
return;
}
let sysroot = std::process::Command::new("rustc")
.arg("--print")
.arg("sysroot")
.output()
.expect("rustc not found")
.stdout;
let sysroot = String::from_utf8(sysroot).expect("sysroot is not utf8");
std::env::set_var("MIRI_SYSROOT", sysroot.trim());
}

fn get_host() -> String {
let rustc = rustc_test_suite().unwrap_or(PathBuf::from("rustc"));
let rustc_version = std::process::Command::new(rustc)
Expand All @@ -117,7 +101,7 @@ fn get_host() -> String {
}

fn get_target() -> String {
std::env::var("MIRI_TARGET").unwrap_or_else(|_| get_host())
std::env::var("MIRI_COMPILETEST_TARGET").unwrap_or_else(|_| get_host())
}

fn run_pass_miri(opt: bool) {
Expand All @@ -129,8 +113,6 @@ fn compile_fail_miri(opt: bool) {
}

fn test_runner(_tests: &[&()]) {
set_sysroot();

run_pass_miri(false);
run_pass_miri(true);

Expand Down
2 changes: 1 addition & 1 deletion travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ echo

echo "Test miri with full MIR, on the host and other architectures"
MIRI_SYSROOT="$MIRI_SYSROOT_BASE"/HOST cargo test --release --all-features
MIRI_SYSROOT="$MIRI_SYSROOT_BASE" MIRI_TARGET="$FOREIGN_TARGET" cargo test --release --all-features
MIRI_SYSROOT="$MIRI_SYSROOT_BASE" MIRI_COMPILETEST_TARGET="$FOREIGN_TARGET" cargo test --release --all-features
echo

echo "Test cargo integration"
Expand Down

0 comments on commit 5c5cc2a

Please sign in to comment.