Skip to content

Commit

Permalink
test(cli): disable codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-0acf4 committed Mar 6, 2024
1 parent 7b096a4 commit 4e1a774
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 66 deletions.
132 changes: 66 additions & 66 deletions meta-cli/src/codegen/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,69 +462,69 @@ impl IntoJson for HashMap<String, Value> {
}
}

#[cfg(test)]
mod tests {
use std::sync::Arc;

use normpath::PathExt;
use pathdiff::diff_paths;
use tokio::sync::mpsc;

use super::*;
use crate::config::Config;
use crate::deploy::actors::console::ConsoleActor;
use crate::deploy::actors::loader::{LoadModule, LoaderActor, LoaderEvent};
use crate::tests::utils::ensure_venv;
use actix::prelude::*;

#[actix::test(flavor = "multi_thread")]
async fn codegen() -> Result<()> {
crate::logger::init();
ensure_venv()?;
let test_folder = Path::new("./src/tests/typegraphs").normalize()?;
std::env::set_current_dir(&test_folder)?;
let tests = fs::read_dir(&test_folder).unwrap();
let config = Config::default_in(".");
let config = Arc::new(config);

for typegraph_test in tests {
let typegraph_test = typegraph_test.unwrap().path();
let typegraph_test = diff_paths(&typegraph_test, &test_folder).unwrap();

let console = ConsoleActor::new(Arc::clone(&config)).start();
let (event_tx, event_rx) = mpsc::unbounded_channel();
let loader = LoaderActor::new(Arc::clone(&config), console, event_tx, 1)
.auto_stop()
.start();
loader.do_send(LoadModule(
test_folder
.join(&typegraph_test)
.as_path()
.to_owned()
.into(),
));

let mut event_rx = event_rx;
// let tg = match event_rx.recv().await.unwrap() {
// LoaderEvent::Typegraph(tg) => tg,
// evt => bail!("unexpected loader evt: {evt:?}"),
// };

// TODO:
// run typegraph! thenget serialized version

// let module_codes = Codegen::new(&tg, &typegraph_test).codegen()?;
// assert_eq!(module_codes.len(), 1);

// let test_name = typegraph_test.to_string_lossy().to_string();
// insta::assert_snapshot!(test_name, &module_codes[0].code);

assert!(matches!(
event_rx.recv().await,
Some(LoaderEvent::Stopped(_))
));
}

Ok(())
}
}
// #[cfg(test)]
// mod tests {
// use std::sync::Arc;

// use normpath::PathExt;
// use pathdiff::diff_paths;
// use tokio::sync::mpsc;

// use super::*;
// use crate::config::Config;
// use crate::deploy::actors::console::ConsoleActor;
// use crate::deploy::actors::loader::{LoadModule, LoaderActor, LoaderEvent};
// use crate::tests::utils::ensure_venv;
// use actix::prelude::*;

// #[actix::test(flavor = "multi_thread")]
// async fn codegen() -> Result<()> {
// crate::logger::init();
// ensure_venv()?;
// let test_folder = Path::new("./src/tests/typegraphs").normalize()?;
// std::env::set_current_dir(&test_folder)?;
// let tests = fs::read_dir(&test_folder).unwrap();
// let config = Config::default_in(".");
// let config = Arc::new(config);

// for typegraph_test in tests {
// let typegraph_test = typegraph_test.unwrap().path();
// let typegraph_test = diff_paths(&typegraph_test, &test_folder).unwrap();

// let console = ConsoleActor::new(Arc::clone(&config)).start();
// let (event_tx, event_rx) = mpsc::unbounded_channel();
// let loader = LoaderActor::new(Arc::clone(&config), console, event_tx, 1)
// .auto_stop()
// .start();
// loader.do_send(LoadModule(
// test_folder
// .join(&typegraph_test)
// .as_path()
// .to_owned()
// .into(),
// ));

// let mut event_rx = event_rx;
// // let tg = match event_rx.recv().await.unwrap() {
// // LoaderEvent::Typegraph(tg) => tg,
// // evt => bail!("unexpected loader evt: {evt:?}"),
// // };

// // TODO:
// // run typegraph! thenget serialized version

// // let module_codes = Codegen::new(&tg, &typegraph_test).codegen()?;
// // assert_eq!(module_codes.len(), 1);

// // let test_name = typegraph_test.to_string_lossy().to_string();
// // insta::assert_snapshot!(test_name, &module_codes[0].code);

// assert!(matches!(
// event_rx.recv().await,
// Some(LoaderEvent::Stopped(_))
// ));
// }

// Ok(())
// }
// }
2 changes: 2 additions & 0 deletions meta-cli/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use anyhow::{bail, Context, Result};
use std::path::PathBuf;
use std::process::{Command, Stdio};

#[allow(unused)]
fn get_workspace_root() -> Result<PathBuf> {
let p = Command::new("cargo")
.arg("metadata")
Expand All @@ -30,6 +31,7 @@ fn get_workspace_root() -> Result<PathBuf> {
bail!("could not read workspace root from cargo metadata")
}

#[allow(unused)]
pub fn ensure_venv() -> Result<()> {
crate::utils::ensure_venv(get_workspace_root()?.join("typegraph"))
}
Expand Down

0 comments on commit 4e1a774

Please sign in to comment.