Skip to content

Commit 2b77970

Browse files
committed
Test for --use-core.
1 parent 264b847 commit 2b77970

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

tests/expectations/tests/use-core.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
extern crate core;
7+
8+
#[repr(C)]
9+
#[derive(Debug, Copy)]
10+
pub struct foo {
11+
pub a: ::std::os::raw::c_int,
12+
pub b: ::std::os::raw::c_int,
13+
pub bar: *mut ::std::os::raw::c_void,
14+
}
15+
#[test]
16+
fn bindgen_test_layout_foo() {
17+
assert_eq!(::core::mem::size_of::<foo>() , 16usize);
18+
assert_eq!(::core::mem::align_of::<foo>() , 8usize);
19+
}
20+
impl Clone for foo {
21+
fn clone(&self) -> Self { *self }
22+
}

tests/headers/use-core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// bindgen-flags: --use-core --raw-line "extern crate core;"
2+
3+
struct foo {
4+
int a, b;
5+
void* bar;
6+
};

tests/tools/run-bindgen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import subprocess
1010
import tempfile
11+
import shlex
1112

1213
BINDGEN_FLAGS_PREFIX = "// bindgen-flags: "
1314

@@ -94,7 +95,7 @@ def get_bindgen_flags(header_path):
9495
with open(header_path) as f:
9596
for line in f:
9697
if line.startswith(BINDGEN_FLAGS_PREFIX):
97-
flags.extend(line.strip().split(BINDGEN_FLAGS_PREFIX)[1].split(" "))
98+
flags.extend(shlex.split(line.strip().split(BINDGEN_FLAGS_PREFIX)[1]))
9899
break
99100

100101
return flags

0 commit comments

Comments
 (0)