diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-07-13 14:17:53 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-07-13 14:17:53 -0700 |
commit | 84e9521c8a5cd63cfe65f42478ca999812cd069d (patch) | |
tree | b70f6865ec007ccc331219775aef8ff825407253 /tests/tests.rs | |
parent | 1b815d61df3e8736ee35f1799a5b231b0b632202 (diff) |
Add the ability to dump preprocessed input headers
This is useful when debugging bindgen, using C-Reduce on an input to bindgen, or
for constructing portable test cases when filing issues against bindgen.
Fixes #811
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 24d5770e..69500268 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -238,3 +238,31 @@ fn no_system_header_includes() { .expect("should wait for ./ci/no-includes OK") .success()); } + +#[test] +fn dump_preprocessed_input() { + let arg_keyword = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp"); + let empty_layout = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/cpp-empty-layout.hpp"); + + builder() + .header(arg_keyword) + .header(empty_layout) + .dump_preprocessed_input() + .expect("should dump preprocessed input"); + + fn slurp(p: &str) -> String { + let mut contents = String::new(); + let mut file = fs::File::open(p).unwrap(); + file.read_to_string(&mut contents).unwrap(); + contents + } + + let bindgen_ii = slurp("__bindgen.ii"); + let arg_keyword = slurp(arg_keyword); + let empty_layout = slurp(empty_layout); + + assert!(bindgen_ii.find(&arg_keyword).is_some(), + "arg_keyword.hpp is in the preprocessed file"); + assert!(bindgen_ii.find(&empty_layout).is_some(), + "cpp-empty-layout.hpp is in the preprocessed file"); +} |