Skip to content

Commit

Permalink
cxx-qt-gen: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Sep 4, 2024
1 parent 43d6ddd commit 4e950ee
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 27 deletions.
14 changes: 2 additions & 12 deletions crates/cxx-qt-gen/src/generator/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ mod tests {

use super::*;

use crate::tests::assert_tokens_eq;

#[test]
fn test_generated_rust_blocks() {
let module: ItemMod = parse_quote! {
Expand All @@ -127,15 +125,7 @@ mod tests {

let rust = GeneratedRustBlocks::from(&parser).unwrap();
assert!(rust.cxx_mod.content.is_none());
assert_eq!(rust.cxx_mod_contents.len(), 1);
assert_tokens_eq(
&rust.cxx_mod_contents[0],
quote! {
unsafe extern "C++" {
include!("cxx-qt-gen/ffi.cxxqt.h");
}
},
);
assert_eq!(rust.cxx_mod_contents.len(), 0);
assert_eq!(rust.namespace, "");
assert_eq!(rust.fragments.len(), 1);
}
Expand All @@ -155,7 +145,7 @@ mod tests {

let rust = GeneratedRustBlocks::from(&parser).unwrap();
assert!(rust.cxx_mod.content.is_none());
assert_eq!(rust.cxx_mod_contents.len(), 1);
assert_eq!(rust.cxx_mod_contents.len(), 0);
assert_eq!(rust.namespace, "cxx_qt");
assert_eq!(rust.fragments.len(), 1);
}
Expand Down
16 changes: 6 additions & 10 deletions crates/cxx-qt-gen/src/writer/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ mod tests {
cxx_mod: parse_quote! {
mod ffi {}
},
cxx_mod_contents: vec![parse_quote! {
unsafe extern "C++" {
include!("myobject.cxxqt.h");
}
}],
cxx_mod_contents: vec![],
namespace: "cxx_qt::my_object".to_owned(),
fragments: vec![GeneratedRustFragment {
cxx_mod_contents: vec![
Expand Down Expand Up @@ -144,11 +140,7 @@ mod tests {
cxx_mod: parse_quote! {
mod ffi {}
},
cxx_mod_contents: vec![parse_quote! {
unsafe extern "C++" {
include!("multiobject.cxxqt.h");
}
}],
cxx_mod_contents: vec![],
namespace: "cxx_qt".to_owned(),
fragments: vec![
GeneratedRustFragment {
Expand Down Expand Up @@ -221,11 +213,13 @@ mod tests {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;

#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}

Expand Down Expand Up @@ -267,11 +261,13 @@ mod tests {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;

#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}

Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/inheritance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ mod inheritance {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/invokables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ mod ffi {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ pub mod ffi {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ mod ffi {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/qenum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ mod ffi {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ mod ffi {
#[doc(hidden)]
#[namespace = "Qt"]
#[rust_name = "CxxQtConnectionType"]
#[allow(dead_code)]
type ConnectionType = cxx_qt::ConnectionType;
#[doc(hidden)]
#[namespace = "rust::cxxqt1"]
#[rust_name = "CxxQtQMetaObjectConnection"]
#[allow(dead_code)]
type QMetaObjectConnection = cxx_qt::QMetaObjectConnection;
}
unsafe extern "C++" {
Expand Down
6 changes: 1 addition & 5 deletions crates/qt-build-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,11 +984,7 @@ Q_IMPORT_PLUGIN({plugin_class_name});
std::fs::create_dir_all(&output_folder).expect("Could not create qrc dir");
let output_path = output_folder.join(format!(
"{}.cpp",
input_path
.file_name()
.unwrap()
.to_string_lossy()
.to_string(),
input_path.file_name().unwrap().to_string_lossy(),
));

let cmd = Command::new(self.rcc_executable.as_ref().unwrap())
Expand Down

0 comments on commit 4e950ee

Please sign in to comment.