summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-06 12:43:45 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-06 12:43:45 +0100
commit2b77970303764ce1bfb14f29058bde3f5cd635cd (patch)
tree9cf95f1fcdb6b93ccb52842123fa9b8d0a73a57a
parent264b847383a51afc30a77d4caa0ae0ab42f3dae8 (diff)
Test for --use-core.
-rw-r--r--tests/expectations/tests/use-core.rs22
-rw-r--r--tests/headers/use-core.h6
-rwxr-xr-xtests/tools/run-bindgen.py3
3 files changed, 30 insertions, 1 deletions
diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs
new file mode 100644
index 00000000..484105ea
--- /dev/null
+++ b/tests/expectations/tests/use-core.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+extern crate core;
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+ pub bar: *mut ::std::os::raw::c_void,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::core::mem::size_of::<foo>() , 16usize);
+ assert_eq!(::core::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/tests/headers/use-core.h b/tests/headers/use-core.h
new file mode 100644
index 00000000..535d2b15
--- /dev/null
+++ b/tests/headers/use-core.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --use-core --raw-line "extern crate core;"
+
+struct foo {
+ int a, b;
+ void* bar;
+};
diff --git a/tests/tools/run-bindgen.py b/tests/tools/run-bindgen.py
index aad210da..519e6891 100755
--- a/tests/tools/run-bindgen.py
+++ b/tests/tools/run-bindgen.py
@@ -8,6 +8,7 @@ import os
import sys
import subprocess
import tempfile
+import shlex
BINDGEN_FLAGS_PREFIX = "// bindgen-flags: "
@@ -94,7 +95,7 @@ def get_bindgen_flags(header_path):
with open(header_path) as f:
for line in f:
if line.startswith(BINDGEN_FLAGS_PREFIX):
- flags.extend(line.strip().split(BINDGEN_FLAGS_PREFIX)[1].split(" "))
+ flags.extend(shlex.split(line.strip().split(BINDGEN_FLAGS_PREFIX)[1]))
break
return flags