diff --git a/.travis.yml b/.travis.yml index e6450622b2..7cc14234ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,16 +6,29 @@ before_script: - rustup target add i686-unknown-linux-gnu - rustup target add i686-pc-windows-gnu - rustup target add i686-pc-windows-msvc +- rustup component add rust-src +- chmod +x -R ~/.rustup/toolchains/*/lib/rustlib/src/rust/src/jemalloc/include/jemalloc/ +- cargo install xargo +- export RUST_SYSROOT=$HOME/rust script: - | - export RUST_SYSROOT=$HOME/rust && + # Test plain miri cargo build && cargo test && - cargo install && + cargo install +- | + # Test cargo miri cd cargo-miri-test && cargo miri && cargo miri test && cd .. +- | + # get ourselves a MIR-ful libstd + cd xargo && + RUSTFLAGS='-Zalways-encode-mir' xargo build && + cd .. && + # and run the tests with it + MIRI_SYSROOT=~/.xargo/HOST cargo test notifications: email: on_success: never diff --git a/README.md b/README.md index fa3fea79e9..d5873c9868 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ RUSTFLAGS='-Zalways-encode-mir' xargo build Now you can run miri against the libstd compiled by xargo: ```sh -cargo run --bin miri -- --sysroot ~/.xargo/HOST tests/run-pass/vecs.rs +MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass/vecs.rs ``` Notice that you will have to re-run the last step of the preparations above when diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 3af3bee3c8..8d27f9057f 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -175,6 +175,10 @@ fn init_logger() { } fn find_sysroot() -> String { + if let Ok(sysroot) = std::env::var("MIRI_SYSROOT") { + return sysroot; + } + // Taken from https://github.com/Manishearth/rust-clippy/pull/911. let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); diff --git a/tests/compile-fail/stack_limit.rs b/tests/compile-fail/stack_limit.rs index 4b61e12d60..c6aaf80e6a 100644 --- a/tests/compile-fail/stack_limit.rs +++ b/tests/compile-fail/stack_limit.rs @@ -1,24 +1,18 @@ #![feature(custom_attribute, attr_literals)] #![miri(stack_limit=16)] +//error-pattern: reached the configured maximum number of stack frames + fn bar() { foo(); } fn foo() { - cake(); //~ ERROR reached the configured maximum number of stack frames + cake(); } fn cake() { - flubber(3); -} - -fn flubber(i: u32) { - if i > 0 { - flubber(i-1); - } else { - bar(); - } + bar(); } fn main() { diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 78b2a2f3ce..e6535ef021 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -65,14 +65,16 @@ fn for_all_targets(sysroot: &Path, mut f: F) { #[test] fn compile_test() { - let sysroot = std::process::Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output() - .expect("rustc not found") - .stdout; - let sysroot = std::str::from_utf8(&sysroot).expect("sysroot is not utf8").trim(); - let sysroot = &Path::new(&sysroot); + let sysroot = std::env::var("MIRI_SYSROOT").unwrap_or_else(|_| { + let sysroot = std::process::Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output() + .expect("rustc not found") + .stdout; + String::from_utf8(sysroot).expect("sysroot is not utf8") + }); + let sysroot = &Path::new(sysroot.trim()); let host = std::process::Command::new("rustc") .arg("-vV") .output()