Skip to content

Commit

Permalink
Add standalone test
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaoliello committed Oct 18, 2023
1 parent 9359ad8 commit e89a902
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/tests/standalone/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ fn main() {
"Windows.Win32.Security.Cryptography.CMC_ADD_ATTRIBUTES",
],
);

// Ensure that no-inner-attribute works, and the resulting
// file can be `include!` inside a mod{} block.
write_no_inner_attr(
"src/b_include_me.rs",
&["Windows.Win32.System.SystemInformation.GetVersion"],
);
}

fn write_sys(output: &str, filter: &[&str]) {
Expand All @@ -149,6 +156,10 @@ fn write_std(output: &str, filter: &[&str]) {
riddle(output, filter, &["flatten", "std", "minimal"]);
}

fn write_no_inner_attr(output: &str, filter: &[&str]) {
riddle(output, filter, &["flatten", "no-inner-attributes", "minimal"]);
}

fn riddle(output: &str, filter: &[&str], config: &[&str]) {
std::fs::remove_file(output).expect("Failed to delete output");

Expand Down
7 changes: 7 additions & 0 deletions crates/tests/standalone/src/b_include_me.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Bindings generated by `windows-bindgen` 0.52.0

#[inline]
pub unsafe fn GetVersion() -> u32 {
::windows_targets::link!("kernel32.dll" "system" fn GetVersion() -> u32);
GetVersion()
}
11 changes: 11 additions & 0 deletions crates/tests/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ mod b_test;
mod b_unknown;
mod b_uri;
mod b_win_enumerator;
#[allow(non_snake_case)]
mod included {
include!("b_include_me.rs");
}

#[test]
fn bstr() {
Expand Down Expand Up @@ -166,3 +170,10 @@ fn calendar() -> windows_core::Result<()> {
calendar.SetYear(year)?;
Ok(())
}

#[test]
fn from_included() {
unsafe {
included::GetVersion();
}
}

0 comments on commit e89a902

Please sign in to comment.