diff options
| author | Ralf Jung <post@ralfj.de> | 2017-08-03 11:36:58 -0700 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2017-08-03 11:38:00 -0700 |
| commit | de1376f923055bee1c3dfc24de23fcab3e2e9f0b (patch) | |
| tree | dda86869e70a5c3a6119e77b0324875db740e203 | |
| parent | f7bc6ab162cf5dfda7f41fa09c413e9e1908cd2b (diff) | |
| download | rust-de1376f923055bee1c3dfc24de23fcab3e2e9f0b.tar.gz rust-de1376f923055bee1c3dfc24de23fcab3e2e9f0b.zip | |
Add a build script to inform the binary about its profile, and use that in the test suite
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | build.rs | 6 | ||||
| -rw-r--r-- | tests/compiletest.rs | 11 |
3 files changed, 12 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml index bfe450c6088..d674cc10d3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ license = "MIT/Apache-2.0" name = "miri" repository = "https://github.com/solson/miri" version = "0.1.0" +build = "build.rs" [[bin]] doc = false diff --git a/build.rs b/build.rs new file mode 100644 index 00000000000..86ccf3cda1a --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +use std::env; + +fn main() { + // Forward the profile to the main compilation + println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); +} diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 0f8865864ce..c7e6149723d 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -13,16 +13,15 @@ macro_rules! eprintln { } } -#[cfg(debug_assertions)] -const MIRI_PATH: &str = "target/debug/miri"; -#[cfg(not(debug_assertions))] -const MIRI_PATH: &str = "target/release/miri"; +fn miri_path() -> String { + format!("target/{}/miri", env!("PROFILE")) +} fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) { eprintln!("## Running compile-fail tests in {} against miri for target {}", path, target); let mut config = compiletest::default_config(); config.mode = "compile-fail".parse().expect("Invalid mode"); - config.rustc_path = MIRI_PATH.into(); + config.rustc_path = miri_path().into(); if fullmir { if host != target { // skip fullmir on nonhost @@ -61,7 +60,7 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) { config.src_base = PathBuf::from(path); config.target = target.to_owned(); config.host = host.to_owned(); - config.rustc_path = MIRI_PATH.into(); + config.rustc_path = miri_path().into(); let mut flags = Vec::new(); if fullmir { if host != target { |
