From 7dd24b363d0a27b4b7fb27782201eda808952f11 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Thu, 28 Jul 2022 23:29:52 +0800 Subject: [PATCH] Exporting existing models is already handled by the "export-validator" --- Cargo.lock | 2 - crates/fj-app/Cargo.toml | 4 -- crates/fj-app/tests/smoke_test.rs | 77 ------------------------------- crates/fj/src/abi/mod.rs | 10 ++-- 4 files changed, 5 insertions(+), 88 deletions(-) delete mode 100644 crates/fj-app/tests/smoke_test.rs diff --git a/Cargo.lock b/Cargo.lock index 94c9713471..4b914aefd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -852,8 +852,6 @@ dependencies = [ "fj-viewer", "fj-window", "serde", - "stl", - "tempfile", "tracing-subscriber", ] diff --git a/crates/fj-app/Cargo.toml b/crates/fj-app/Cargo.toml index 0e9d64637a..8483e86163 100644 --- a/crates/fj-app/Cargo.toml +++ b/crates/fj-app/Cargo.toml @@ -62,7 +62,3 @@ features = ["derive"] [dependencies.tracing-subscriber] version = "0.3.15" features = ["env-filter", "fmt"] - -[dev-dependencies] -stl = "0.2.1" -tempfile = "3.3.0" diff --git a/crates/fj-app/tests/smoke_test.rs b/crates/fj-app/tests/smoke_test.rs deleted file mode 100644 index d838725a9b..0000000000 --- a/crates/fj-app/tests/smoke_test.rs +++ /dev/null @@ -1,77 +0,0 @@ -use std::{ - fs::File, - path::Path, - process::{Command, Output, Stdio}, -}; - -use stl::BinaryStlFile; -use tempfile::TempDir; - -const FJ_APP: &str = env!("CARGO_BIN_EXE_fj-app"); - -#[test] -fn spacer() { - let BinaryStlFile { header, triangles } = execute_model("spacer"); - assert_eq!(header.num_triangles, 42); - assert_eq!(header.num_triangles as usize, triangles.len()); -} - -#[test] -fn test() { - let BinaryStlFile { header, triangles } = execute_model("test"); - assert_eq!(header.num_triangles, 42); - assert_eq!(header.num_triangles as usize, triangles.len()); -} - -#[test] -fn cuboid() { - let BinaryStlFile { header, triangles } = execute_model("cuboid"); - assert_eq!(header.num_triangles, 42); - assert_eq!(header.num_triangles as usize, triangles.len()); -} - -#[test] -fn star() { - let BinaryStlFile { header, triangles } = execute_model("star"); - assert_eq!(header.num_triangles, 42); - assert_eq!(header.num_triangles as usize, triangles.len()); -} - -fn execute_model(name: &str) -> BinaryStlFile { - let project_root = Path::new(env!("CARGO_MANIFEST_DIR")) - .ancestors() - .nth(2) - .unwrap(); - let temp = TempDir::new().unwrap(); - let dest = temp.path().join("output.stl"); - - let mut cmd = Command::new(FJ_APP); - cmd.arg("--model") - .arg(name) - .arg("--export") - .arg(&dest) - .env("RUST_BACKTRACE", "1") - .env("RUST_LOG", "debug") - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .current_dir(&project_root); - let Output { - status, - stdout, - stderr, - } = cmd.output().unwrap(); - - let stdout = String::from_utf8(stdout).unwrap(); - let stderr = String::from_utf8(stderr).unwrap(); - - if !status.success() { - println!("---- Stdout ----"); - println!("{stdout}"); - println!("---- Stderr ----"); - println!("{stderr}"); - panic!("`{cmd:?}` failed with exit code {:?}", status.code()); - } - - let mut f = File::open(&dest).unwrap(); - stl::read_stl(&mut f).unwrap() -} diff --git a/crates/fj/src/abi/mod.rs b/crates/fj/src/abi/mod.rs index d9144a845e..6f9c2d49e6 100644 --- a/crates/fj/src/abi/mod.rs +++ b/crates/fj/src/abi/mod.rs @@ -59,14 +59,14 @@ macro_rules! register_model { unsafe extern "C" fn fj_model_init( mut host: *mut $crate::abi::Host<'_>, ) -> $crate::abi::InitResult { - let host: &mut dyn $crate::Host = &mut *host; - - let result: Result< + let init: fn( + &mut dyn $crate::Host, + ) -> Result< $crate::PluginMetadata, Box, - > = $init(host); + > = $init; - match result { + match init(&mut *host) { Ok(meta) => $crate::abi::InitResult::Ok(meta.into()), Err(e) => $crate::abi::InitResult::Err(e.into()), }