diff --git a/build.rs b/build.rs index 768db4d..5644b02 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,6 @@ fn generate_tests() { use std::io::Write; use std::path::{Path, PathBuf}; - let profile = env::var("PROFILE").unwrap(); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut dst = File::create(Path::new(&out_dir).join("tests.rs")).unwrap(); @@ -17,6 +16,19 @@ fn generate_tests() { println!("cargo:rerun-if-changed={}", tests_dir.display()); + // Try to make a decent guess at where our binary will end up in. + // + // TODO(emilio): Ideally running tests will just use the library-version of + // cbindgen instead of the built binary. + let cbindgen_path = out_dir + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .join("cbindgen"); + for entry in entries { let path_segment = if entry.file_type().unwrap().is_file() { match entry.path().extension().and_then(OsStr::to_str) { @@ -41,8 +53,8 @@ fn generate_tests() { writeln!( dst, - "test_file!({}, test_{}, {:?}, {:?});", - profile, + "test_file!({:?}, test_{}, {:?}, {:?});", + cbindgen_path, identifier, path_segment, entry.path(), diff --git a/tests/tests.rs b/tests/tests.rs index 3870444..5fd78e6 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -6,19 +6,14 @@ use std::process::Command; use std::{env, fs}; fn run_cbindgen( - profile: &'static str, + cbindgen_path: &'static str, path: &Path, output: &Path, language: Language, style: Option