From c5995bda24d628ddecda8bbe10db9b4415cc973a Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 12 Aug 2022 13:36:16 -0500 Subject: test warning emission --- tests/expectations/tests/allowlist_warnings.rs | 6 ++++++ tests/headers/allowlist_warnings.h | 2 ++ tests/tests.rs | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/expectations/tests/allowlist_warnings.rs create mode 100644 tests/headers/allowlist_warnings.h diff --git a/tests/expectations/tests/allowlist_warnings.rs b/tests/expectations/tests/allowlist_warnings.rs new file mode 100644 index 00000000..131dbdf3 --- /dev/null +++ b/tests/expectations/tests/allowlist_warnings.rs @@ -0,0 +1,6 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] diff --git a/tests/headers/allowlist_warnings.h b/tests/headers/allowlist_warnings.h new file mode 100644 index 00000000..83c9e259 --- /dev/null +++ b/tests/headers/allowlist_warnings.h @@ -0,0 +1,2 @@ +// bindgen-flags: --allowlist-function "doesnt_match_anything" +int non_matched_function(int arg); diff --git a/tests/tests.rs b/tests/tests.rs index cc64cfdd..7b46df5e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -670,3 +670,19 @@ fn dump_preprocessed_input() { "cpp-empty-layout.hpp is in the preprocessed file" ); } + +#[test] +fn allowlist_warnings() { + let header = concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/headers/allowlist_warnings.h" + ); + + let mut bindings = builder() + .header(header) + .allowlist_function("doesnt_match_anything") + .generate() + .expect("unable to generate bindings"); + + assert_eq!(1, bindings.take_warnings().count()); +} -- cgit v1.2.3