Move C++ generated code test to cxx's integration test
diff --git a/Cargo.toml b/Cargo.toml
index 57b4320..d8b93f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,6 +29,7 @@
[dev-dependencies]
cxx-build = { version = "=0.4.7", path = "gen/build" }
+cxx-gen = { version = "0.4", path = "gen/lib" }
cxx-test-suite = { version = "0", path = "tests/ffi" }
rustversion = "1.0"
trybuild = { version = "1.0.33", features = ["diff"] }
diff --git a/gen/src/mod.rs b/gen/src/mod.rs
index 8522715..2fee0e9 100644
--- a/gen/src/mod.rs
+++ b/gen/src/mod.rs
@@ -8,9 +8,6 @@
pub(super) mod out;
mod write;
-#[cfg(test)]
-mod tests;
-
pub(super) use self::error::Error;
use self::error::{format_err, Result};
use self::file::File;
diff --git a/gen/src/tests.rs b/gen/src/tests.rs
deleted file mode 100644
index dbf4c62..0000000
--- a/gen/src/tests.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use crate::gen::{generate_from_string, Opt};
-
-const CPP_EXAMPLE: &str = r#"
- #[cxx::bridge]
- mod ffi {
- extern "C" {
- pub fn do_cpp_thing(foo: &str);
- }
- }
-"#;
-
-#[test]
-fn test_cpp() {
- let opts = Opt {
- include: Vec::new(),
- cxx_impl_annotations: None,
- gen_header: false,
- gen_implementation: true,
- };
- let output = generate_from_string(CPP_EXAMPLE, &opts).unwrap();
- let output = std::str::from_utf8(&output.implementation).unwrap();
- // To avoid continual breakage we won't test every byte.
- // Let's look for the major features.
- assert!(output.contains("void cxxbridge04$do_cpp_thing(::rust::Str::Repr foo)"));
-}
-
-#[test]
-fn test_annotation() {
- let opts = Opt {
- include: Vec::new(),
- cxx_impl_annotations: Some("ANNOTATION".to_string()),
- gen_header: false,
- gen_implementation: true,
- };
- let output = generate_from_string(CPP_EXAMPLE, &opts).unwrap();
- let output = std::str::from_utf8(&output.implementation).unwrap();
- assert!(output.contains("ANNOTATION void cxxbridge04$do_cpp_thing(::rust::Str::Repr foo)"));
-}
diff --git a/tests/cxx_gen.rs b/tests/cxx_gen.rs
new file mode 100644
index 0000000..b5ff106
--- /dev/null
+++ b/tests/cxx_gen.rs
@@ -0,0 +1,31 @@
+use cxx_gen::{generate_header_and_cc, Opt};
+
+const CPP_EXAMPLE: &str = r#"
+ #[cxx::bridge]
+ mod ffi {
+ extern "C" {
+ pub fn do_cpp_thing(foo: &str);
+ }
+ }
+"#;
+
+#[test]
+fn test_cpp() {
+ let opt = Opt::default();
+ let source = CPP_EXAMPLE.parse().unwrap();
+ let output = generate_header_and_cc(source, &opt).unwrap();
+ let output = std::str::from_utf8(&output.implementation).unwrap();
+ // To avoid continual breakage we won't test every byte.
+ // Let's look for the major features.
+ assert!(output.contains("void cxxbridge04$do_cpp_thing(::rust::Str::Repr foo)"));
+}
+
+#[test]
+fn test_annotation() {
+ let mut opt = Opt::default();
+ opt.cxx_impl_annotations = Some("ANNOTATION".to_owned());
+ let source = CPP_EXAMPLE.parse().unwrap();
+ let output = generate_header_and_cc(source, &opt).unwrap();
+ let output = std::str::from_utf8(&output.implementation).unwrap();
+ assert!(output.contains("ANNOTATION void cxxbridge04$do_cpp_thing(::rust::Str::Repr foo)"));
+}