Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ env:
- LLVM_VERSION="3.8.1" BINDGEN_JOB="test" BINDGEN_PROFILE="--release"
- LLVM_VERSION="3.8.1" BINDGEN_JOB="integration" BINDGEN_PROFILE=
- LLVM_VERSION="3.8.1" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release"
- LLVM_VERSION="3.8.1" BINDGEN_JOB="expectations" BINDGEN_PROFILE=
- LLVM_VERSION="3.8.1" BINDGEN_JOB="expectations" BINDGEN_PROFILE="--release"
- LLVM_VERSION="3.9.0" BINDGEN_JOB="test" BINDGEN_PROFILE=
- LLVM_VERSION="3.9.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release"
- LLVM_VERSION="3.9.0" BINDGEN_JOB="integration" BINDGEN_PROFILE=
- LLVM_VERSION="3.9.0" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release"
- LLVM_VERSION="3.9.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE=
- LLVM_VERSION="3.9.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE="--release"
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE=
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release"
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE= BINDGEN_FEATURES="testing_only_extra_assertions"
Expand Down
60 changes: 60 additions & 0 deletions tests/expectations/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//! Generate a module with a custom `#[path=...]` for each of the files in our
//! libclang version-specific test expectations so that they get their layout
//! tests run. We need to do this because cargo doesn't automatically detect
//! tests subdirectories.

use std::env;
use std::fs;
use std::io::Write;
use std::path::Path;

const LIBCLANG_VERSION_DIRS: &'static [&'static str] =
&["libclang-3.8", "libclang-3.9", "libclang-4"];

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let mut test_string = String::new();

for dir in LIBCLANG_VERSION_DIRS {
let dir = Path::new(&env::var_os("CARGO_MANIFEST_DIR").unwrap())
.join("tests")
.join(dir);

println!("cargo:rerun-if-changed={}", dir.display());

for entry in fs::read_dir(dir).unwrap() {
let entry = entry.unwrap();
let path = entry.path();
let path = path.canonicalize().unwrap_or_else(|_| path.into());
if path.extension().map(|e| e.to_string_lossy()) != Some("rs".into()) {
continue;
}

println!("cargo:rerun-if-changed={}", path.display());

let module_name: String = path.display()
.to_string()
.chars()
.map(|c| match c {
'a'...'z' | 'A'...'Z' | '0'...'9' => c,
_ => '_',
})
.collect();

test_string.push_str(&format!(
r###"
#[path = "{}"]
mod {};
"###,
path.display(),
module_name,
));
}
}

let out_path = Path::new(&env::var_os("OUT_DIR").unwrap())
.join("libclang_version_specific_generated_tests.rs");
let mut test_file = fs::File::create(out_path).unwrap();
test_file.write_all(test_string.as_bytes()).unwrap();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/libclang_version_specific_generated_tests.rs"));