Skip to content

Commit f044205

Browse files
committed
the test suite assumes a libstd with full MIR; run test suite on xargo-built foreign libstds
1 parent b6eb2cd commit f044205

File tree

84 files changed

+22
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+22
-50
lines changed

.travis.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,35 @@ before_script:
2020
else
2121
RUST_TOOLCHAIN=$(cat rust-version)
2222
fi
23+
- |
24+
if [ "$TRAVIS_OS_NAME" == osx ]; then
25+
export MIRI_SYSROOT_BASE=~/Library/Caches/miri.miri.miri/
26+
else
27+
export MIRI_SYSROOT_BASE=~/.cache/miri/HOST
28+
fi
2329
# install Rust
2430
- curl https://build.travis-ci.org/files/rustup-init.sh -sSf | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN"
2531
- export PATH=$HOME/.cargo/bin:$PATH
2632
- rustc --version
27-
# customize installation
28-
- rustup target add i686-unknown-linux-gnu
29-
- rustup target add i686-pc-windows-gnu
30-
- rustup target add i686-pc-windows-msvc
3133

3234
script:
3335
- set -e
3436
- |
35-
# Test and install plain miri
37+
# Build and install miri
3638
cargo build --release --all-features --all-targets &&
37-
cargo test --release --all-features &&
3839
cargo install --all-features --force --path .
3940
- |
40-
# Get ourselves a MIR-full libstd, and use it henceforth
41+
# Get ourselves a MIR-full libstd
4142
cargo miri setup &&
42-
if [ "$TRAVIS_OS_NAME" == osx ]; then
43-
export MIRI_SYSROOT=~/Library/Caches/miri.miri.miri/HOST
44-
else
45-
export MIRI_SYSROOT=~/.cache/miri/HOST
46-
fi
43+
cargo miri setup --target i686-unknown-linux-gnu &&
44+
cargo miri setup --target i686-apple-darwin
4745
- |
48-
# Test miri with full MIR
49-
cargo test --release --all-features
46+
# Test miri with full MIR, on the host and other architectures
47+
MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST cargo test --release --all-features &&
48+
MIRI_SYSROOT=$MIRI_SYSROOT_BASE cargo test --release --all-features
5049
- |
5150
# Test cargo integration
52-
(cd cargo-miri-test && ./run-test.py)
51+
(cd test-cargo-miri && MIRI_SYSROOT=$MIRI_SYSROOT_BASE/HOST ./run-test.py)
5352
5453
notifications:
5554
email:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/compiletest.rs

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(slice_concat_ext, custom_test_frameworks)]
2+
// Custom test runner, to avoid libtest being wrapped around compiletest which wraps libtest.
23
#![test_runner(test_runner)]
34

45
use std::slice::SliceConcatExt;
@@ -24,11 +25,6 @@ fn rustc_lib_path() -> PathBuf {
2425
option_env!("RUSTC_LIB_PATH").unwrap().into()
2526
}
2627

27-
fn have_fullmir() -> bool {
28-
// We assume we have full MIR when MIRI_SYSROOT is set or when we are in rustc
29-
std::env::var("MIRI_SYSROOT").is_ok() || rustc_test_suite().is_some()
30-
}
31-
3228
fn mk_config(mode: &str) -> compiletest::common::ConfigWithTemp {
3329
let mut config = compiletest::Config::default().tempdir();
3430
config.mode = mode.parse().expect("Invalid mode");
@@ -41,16 +37,7 @@ fn mk_config(mode: &str) -> compiletest::common::ConfigWithTemp {
4137
config
4238
}
4339

44-
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: bool, opt: bool) {
45-
if need_fullmir && !have_fullmir() {
46-
eprintln!("{}\n", format!(
47-
"## Skipping compile-fail tests in {} against miri for target {} due to missing mir",
48-
path,
49-
target
50-
).yellow().bold());
51-
return;
52-
}
53-
40+
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, opt: bool) {
5441
let opt_str = if opt { " with optimizations" } else { "" };
5542
eprintln!("{}", format!(
5643
"## Running compile-fail tests in {} against miri for target {}{}",
@@ -78,16 +65,7 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, need_fullm
7865
compiletest::run_tests(&config);
7966
}
8067

81-
fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: bool, opt: bool) {
82-
if need_fullmir && !have_fullmir() {
83-
eprintln!("{}\n", format!(
84-
"## Skipping run-pass tests in {} against miri for target {} due to missing mir",
85-
path,
86-
target
87-
).yellow().bold());
88-
return;
89-
}
90-
68+
fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, opt: bool) {
9169
let opt_str = if opt { " with optimizations" } else { "" };
9270
eprintln!("{}", format!(
9371
"## Running run-pass tests in {} against miri for target {}{}",
@@ -105,10 +83,6 @@ fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir:
10583
// whitelist.
10684
flags.push("-Zmir-opt-level=1".to_owned());
10785
}
108-
if !have_fullmir() {
109-
// FIXME: Validation relies on the EscapeToRaw statements being emitted
110-
flags.push("-Zmiri-disable-validation".to_owned());
111-
}
11286

11387
let mut config = mk_config("ui");
11488
config.src_base = PathBuf::from(path);
@@ -132,7 +106,7 @@ fn target_has_std<P: Into<PathBuf>>(path: P) -> bool {
132106
.map(|entry| entry.unwrap())
133107
.filter(|entry| entry.file_type().unwrap().is_file())
134108
.filter_map(|entry| entry.file_name().into_string().ok())
135-
.any(|file_name| file_name.starts_with("libstd") && file_name.ends_with(".rlib"))
109+
.any(|file_name| file_name == "libstd.rlib")
136110
}
137111

138112

@@ -186,18 +160,17 @@ fn run_pass_miri(opt: bool) {
186160
let host = get_host();
187161

188162
for_all_targets(&sysroot, |target| {
189-
miri_pass(&sysroot, "tests/run-pass", &target, &host, false, opt);
163+
miri_pass(&sysroot, "tests/run-pass", &target, &host, opt);
190164
});
191-
miri_pass(&sysroot, "tests/run-pass-fullmir", &host, &host, true, opt);
192165
}
193166

194167
fn compile_fail_miri(opt: bool) {
195168
let sysroot = get_sysroot();
196169
let host = get_host();
197170

198-
// FIXME: run tests for other targets, too
199-
compile_fail(&sysroot, "tests/compile-fail", &host, &host, false, opt);
200-
compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true, opt);
171+
for_all_targets(&sysroot, |target| {
172+
compile_fail(&sysroot, "tests/compile-fail", &target, &host, opt);
173+
});
201174
}
202175

203176
fn test_runner(_tests: &[&()]) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)