From 6ba01b8dfa5f53bf8ddef65f67a54d48b8d3ad8e Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Mon, 10 Mar 2025 15:43:43 -0400 Subject: [PATCH] sketch a bit more; going to pull this out of tests next --- rust/kcl-lib/src/execution/exec_ast.rs | 39 ++++++++++++++++++++++++++ rust/kcl-lib/src/lib.rs | 2 +- rust/kcl-lib/src/walk/mod.rs | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/rust/kcl-lib/src/execution/exec_ast.rs b/rust/kcl-lib/src/execution/exec_ast.rs index 15aefa6ec..3caf2a0d1 100644 --- a/rust/kcl-lib/src/execution/exec_ast.rs +++ b/rust/kcl-lib/src/execution/exec_ast.rs @@ -2211,4 +2211,43 @@ a = foo() let result = parse_execute(program).await; assert!(result.unwrap_err().to_string().contains("return")); } + + #[tokio::test(flavor = "multi_thread")] + async fn load_all_modules() { + let mut universe = HashMap::>::new(); + + // program a.kcl + let programa = r#" +a = 1 +"#; + let programa = crate::parsing::parse_str(&programa, ModuleId::default()) + .parse_errs_as_err() + .unwrap(); + universe.insert("a.kcl".to_owned(), (&programa).into()); + + // program b.kcl + let programb = r#" +import 'a.kcl' as x +"#; + let programb = crate::parsing::parse_str(&programb, ModuleId::default()) + .parse_errs_as_err() + .unwrap(); + universe.insert("b.kcl".to_owned(), (&programb).into()); + + // program c.kcl + let programc = r#" +import 'a.kcl' +"#; + let programc = crate::parsing::parse_str(&programc, ModuleId::default()) + .parse_errs_as_err() + .unwrap(); + universe.insert("c.kcl".to_owned(), (&programc).into()); + + // ok we have all the "files" loaded, let's do a sort and concurrent + // run here. + + for modules in crate::walk::import_graph(universe).into_iter() { + // + } + } } diff --git a/rust/kcl-lib/src/lib.rs b/rust/kcl-lib/src/lib.rs index 558d63d70..596c6aa8a 100644 --- a/rust/kcl-lib/src/lib.rs +++ b/rust/kcl-lib/src/lib.rs @@ -76,7 +76,7 @@ pub mod std; pub mod test_server; mod thread; mod unparser; -mod walk; +pub mod walk; #[cfg(target_arch = "wasm32")] mod wasm; diff --git a/rust/kcl-lib/src/walk/mod.rs b/rust/kcl-lib/src/walk/mod.rs index 5a3f4c95b..5e04ca66d 100644 --- a/rust/kcl-lib/src/walk/mod.rs +++ b/rust/kcl-lib/src/walk/mod.rs @@ -8,3 +8,4 @@ mod import_graph; pub use ast_node::Node; pub use ast_visitor::Visitable; pub use ast_walk::walk; +pub use import_graph::import_graph;