Skip to content

Commit 44a45f7

Browse files
committed
run test suite also against libstd with full MIR
1 parent 6619ed8 commit 44a45f7

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

.travis.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,29 @@ before_script:
66
- rustup target add i686-unknown-linux-gnu
77
- rustup target add i686-pc-windows-gnu
88
- rustup target add i686-pc-windows-msvc
9+
- rustup component add rust-src
10+
- chmod +x -R ~/.rustup/toolchains/*/lib/rustlib/src/rust/src/jemalloc/include/jemalloc/
11+
- cargo install xargo
12+
- export RUST_SYSROOT=$HOME/rust
913
script:
1014
- |
11-
export RUST_SYSROOT=$HOME/rust &&
15+
# Test plain miri
1216
cargo build &&
1317
cargo test &&
14-
cargo install &&
18+
cargo install
19+
- |
20+
# Test cargo miri
1521
cd cargo-miri-test &&
1622
cargo miri &&
1723
cargo miri test &&
1824
cd ..
25+
- |
26+
# get ourselves a MIR-ful libstd
27+
cd xargo &&
28+
RUSTFLAGS='-Zalways-encode-mir' xargo build &&
29+
cd .. &&
30+
# and run the tests with it
31+
MIRI_SYSROOT=~/.xargo/HOST cargo test
1932
notifications:
2033
email:
2134
on_success: never

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ RUSTFLAGS='-Zalways-encode-mir' xargo build
7171
Now you can run miri against the libstd compiled by xargo:
7272

7373
```sh
74-
cargo run --bin miri -- --sysroot ~/.xargo/HOST tests/run-pass/vecs.rs
74+
MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass/vecs.rs
7575
```
7676

7777
Notice that you will have to re-run the last step of the preparations above when

src/bin/miri.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ fn init_logger() {
175175
}
176176

177177
fn find_sysroot() -> String {
178+
if let Ok(sysroot) = std::env::var("MIRI_SYSROOT") {
179+
return sysroot;
180+
}
181+
178182
// Taken from https://github.com/Manishearth/rust-clippy/pull/911.
179183
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
180184
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));

tests/compile-fail/stack_limit.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
#![feature(custom_attribute, attr_literals)]
22
#![miri(stack_limit=16)]
33

4+
//error-pattern: reached the configured maximum number of stack frames
5+
46
fn bar() {
57
foo();
68
}
79

810
fn foo() {
9-
cake(); //~ ERROR reached the configured maximum number of stack frames
11+
cake();
1012
}
1113

1214
fn cake() {
13-
flubber(3);
14-
}
15-
16-
fn flubber(i: u32) {
17-
if i > 0 {
18-
flubber(i-1);
19-
} else {
20-
bar();
21-
}
15+
bar();
2216
}
2317

2418
fn main() {

tests/compiletest.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ fn for_all_targets<F: FnMut(String)>(sysroot: &Path, mut f: F) {
6565

6666
#[test]
6767
fn compile_test() {
68-
let sysroot = std::process::Command::new("rustc")
69-
.arg("--print")
70-
.arg("sysroot")
71-
.output()
72-
.expect("rustc not found")
73-
.stdout;
74-
let sysroot = std::str::from_utf8(&sysroot).expect("sysroot is not utf8").trim();
75-
let sysroot = &Path::new(&sysroot);
68+
let sysroot = std::env::var("MIRI_SYSROOT").unwrap_or_else(|_| {
69+
let sysroot = std::process::Command::new("rustc")
70+
.arg("--print")
71+
.arg("sysroot")
72+
.output()
73+
.expect("rustc not found")
74+
.stdout;
75+
String::from_utf8(sysroot).expect("sysroot is not utf8")
76+
});
77+
let sysroot = &Path::new(sysroot.trim());
7678
let host = std::process::Command::new("rustc")
7779
.arg("-vV")
7880
.output()

0 commit comments

Comments
 (0)