Skip to content

Commit

Permalink
run test suite also against libstd with full MIR
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 31, 2017
1 parent 6619ed8 commit 44a45f7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
14 changes: 4 additions & 10 deletions tests/compile-fail/stack_limit.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
18 changes: 10 additions & 8 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ fn for_all_targets<F: FnMut(String)>(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()
Expand Down

0 comments on commit 44a45f7

Please sign in to comment.