Skip to content

Commit 6034655

Browse files
authored
Merge pull request rust-lang#205 from RalfJung/tests
run fullmir tests against rustc; add output explaining what is being tested
2 parents d539faf + 8101592 commit 6034655

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/compiletest.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ extern crate compiletest_rs as compiletest;
33
use std::path::{PathBuf, Path};
44
use std::io::Write;
55

6+
macro_rules! eprintln {
7+
($($arg:tt)*) => {
8+
let stderr = std::io::stderr();
9+
writeln!(stderr.lock(), $($arg)*).unwrap();
10+
}
11+
}
12+
613
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) {
14+
eprintln!("## Running compile-fail tests in {} against miri for target {}", path, target);
715
let mut config = compiletest::default_config();
816
config.mode = "compile-fail".parse().expect("Invalid mode");
917
config.rustc_path = "target/debug/miri".into();
@@ -23,16 +31,18 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
2331
compiletest::run_tests(&config);
2432
}
2533

26-
fn run_pass() {
34+
fn run_pass(path: &str) {
35+
eprintln!("## Running run-pass tests in {} against rustc", path);
2736
let mut config = compiletest::default_config();
2837
config.mode = "run-pass".parse().expect("Invalid mode");
29-
config.src_base = PathBuf::from("tests/run-pass".to_string());
38+
config.src_base = PathBuf::from(path);
3039
config.target_rustcflags = Some("-Dwarnings".to_string());
3140
config.host_rustcflags = Some("-Dwarnings".to_string());
3241
compiletest::run_tests(&config);
3342
}
3443

3544
fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool) {
45+
eprintln!("## Running run-pass tests in {} against miri for target {}", path, target);
3646
let mut config = compiletest::default_config();
3747
config.mode = "mir-opt".parse().expect("Invalid mode");
3848
config.src_base = PathBuf::from(path);
@@ -65,13 +75,10 @@ fn is_target_dir<P: Into<PathBuf>>(path: P) -> bool {
6575

6676
fn for_all_targets<F: FnMut(String)>(sysroot: &Path, mut f: F) {
6777
let target_dir = sysroot.join("lib").join("rustlib");
68-
println!("target dir: {}", target_dir.to_str().unwrap());
6978
for entry in std::fs::read_dir(target_dir).expect("invalid sysroot") {
7079
let entry = entry.unwrap();
7180
if !is_target_dir(entry.path()) { continue; }
7281
let target = entry.file_name().into_string().unwrap();
73-
let stderr = std::io::stderr();
74-
writeln!(stderr.lock(), "running tests for target {}", target).unwrap();
7582
f(target);
7683
}
7784
}
@@ -209,7 +216,8 @@ fn compile_test() {
209216

210217
panic!("ran miri on rustc test suite. Test failing for convenience");
211218
} else {
212-
run_pass();
219+
run_pass("tests/run-pass");
220+
run_pass("tests/run-pass-fullmir");
213221
for_all_targets(sysroot, |target| {
214222
miri_pass("tests/run-pass", &target, host, false);
215223
compile_fail(sysroot, "tests/compile-fail", &target, host, false);

0 commit comments

Comments
 (0)