Skip to content

Commit de9911a

Browse files
committed
add tests
Signed-off-by: Jessie Frazelle <github@jessfraz.com>
1 parent 51de408 commit de9911a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#![cfg(feature = "python")]
2+
#![allow(missing_docs)]
3+
4+
use std::{collections::HashSet, path::PathBuf};
5+
6+
#[test]
7+
fn pyclass_enum_renames_are_used_in_stub_generation() {
8+
// Touch the enums so the linker keeps the object files that contain
9+
// the `inventory::submit!` registrations emitted by the derive macros.
10+
use kittycad_modeling_cmds::format;
11+
let _ = std::any::TypeId::of::<format::dxf::export::Storage>();
12+
let _ = std::any::TypeId::of::<format::stl::export::Storage>();
13+
let _ = std::any::TypeId::of::<format::ply::export::Storage>();
14+
let _ = std::any::TypeId::of::<format::fbx::export::Storage>();
15+
let _ = std::any::TypeId::of::<format::gltf::export::Storage>();
16+
17+
// Build stub info from this crate's project root.
18+
let info = pyo3_stub_gen::StubInfo::from_project_root(
19+
"kittycad_modeling_cmds".to_string(),
20+
PathBuf::from(env!("CARGO_MANIFEST_DIR")),
21+
)
22+
.expect("stub info should be collectable with python feature enabled");
23+
24+
// Gather all enum names across all modules.
25+
let mut enum_names = HashSet::new();
26+
for module in info.modules.values() {
27+
for en in module.enum_.values() {
28+
enum_names.insert(en.name);
29+
}
30+
}
31+
32+
// These enums used to be exported as `Storage` which collided.
33+
for expected in ["DxfStorage", "StlStorage", "PlyStorage", "FbxStorage", "GltfStorage"] {
34+
assert!(
35+
enum_names.contains(expected),
36+
"expected renamed enum `{}` to appear in stub info; got {:?}",
37+
expected,
38+
enum_names
39+
);
40+
}
41+
}

0 commit comments

Comments
 (0)