Skip to content

Commit c4fdff8

Browse files
committed
Have tests targetting Linux by default on Windows
1 parent 10ea03c commit c4fdff8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> {
137137
}
138138
}
139139

140+
// Windows platform has various different conventions than *nix platforms,
141+
// e.g. default enum underlying type, struct padding, mangling. Most tests
142+
// were written and checked on Linux and macOS, and thus they could fail on
143+
// Windows. We just make those tests targetting Linux instead as far as one
144+
// isn't annotated for a specific target.
145+
if cfg!(target_os = "windows") {
146+
if flags.iter().all(|flag| !flag.starts_with("--target=")) {
147+
if !flags.iter().any(|flag| flag == "--") {
148+
flags.push("--".into());
149+
}
150+
flags.push("--target=x86_64-unknown-linux".into());
151+
}
152+
}
153+
140154
// Fool builder_from_flags() into believing it has real env::args_os...
141155
// - add "bindgen" as executable name 0th element
142156
// - add header filename as 1st element

0 commit comments

Comments
 (0)