Skip to content

Commit 54a1f07

Browse files
authored
Merge pull request #312 from RalfJung/compiletest
update compiletest, use tempdir
2 parents d38c328 + 2e28e14 commit 54a1f07

File tree

3 files changed

+75
-6
lines changed

3 files changed

+75
-6
lines changed

Cargo.lock

Lines changed: 63 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cargo_miri = ["cargo_metadata"]
3737

3838
[dev-dependencies]
3939
compiletest_rs = "0.2.6"
40+
tempdir = "0.3"
4041

4142
[workspace]
4243
exclude = ["xargo", "cargo-miri-test", "rustc_tests"]

tests/compiletest.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#![feature(slice_concat_ext)]
22

33
extern crate compiletest_rs as compiletest;
4+
extern crate tempdir;
45

56
use std::slice::SliceConcatExt;
67
use std::path::{PathBuf, Path};
78
use std::io::Write;
9+
use tempdir::TempDir;
810

911
macro_rules! eprintln {
1012
($($arg:tt)*) => {
@@ -35,8 +37,10 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
3537
path,
3638
target
3739
);
38-
let mut config = compiletest::default_config();
40+
let build_dir = TempDir::new("miri-tests").unwrap();
41+
let mut config = compiletest::Config::default();
3942
config.mode = "compile-fail".parse().expect("Invalid mode");
43+
config.build_base = build_dir.path().to_owned();
4044
config.rustc_path = miri_path();
4145
let mut flags = Vec::new();
4246
if rustc_test_suite().is_some() {
@@ -66,8 +70,10 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
6670

6771
fn run_pass(path: &str) {
6872
eprintln!("## Running run-pass tests in {} against rustc", path);
69-
let mut config = compiletest::default_config();
73+
let build_dir = TempDir::new("miri-tests").unwrap();
74+
let mut config = compiletest::Config::default();
7075
config.mode = "run-pass".parse().expect("Invalid mode");
76+
config.build_base = build_dir.path().to_owned();
7177
config.src_base = PathBuf::from(path);
7278
if let Some(rustc_path) = rustc_test_suite() {
7379
config.rustc_path = rustc_path;
@@ -89,8 +95,10 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
8995
target,
9096
opt_str
9197
);
92-
let mut config = compiletest::default_config();
98+
let build_dir = TempDir::new("miri-tests").unwrap();
99+
let mut config = compiletest::Config::default();
93100
config.mode = "mir-opt".parse().expect("Invalid mode");
101+
config.build_base = build_dir.path().to_owned();
94102
config.src_base = PathBuf::from(path);
95103
config.target = target.to_owned();
96104
config.host = host.to_owned();

0 commit comments

Comments
 (0)