| @ -797,7 +797,7 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr | |||||||
|             let ctx = crate::ExecutorContext { |             let ctx = crate::ExecutorContext { | ||||||
|                 engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())), |                 engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())), | ||||||
|                 fs: std::sync::Arc::new(crate::fs::FileManager::new()), |                 fs: std::sync::Arc::new(crate::fs::FileManager::new()), | ||||||
|                 stdlib: std::sync::Arc::new(crate::std::StdLib::new()), |                 stdlib: std::sync::Arc::new(tokio::sync::RwLock::new(crate::std::StdLib::new())), | ||||||
|                 settings: Default::default(), |                 settings: Default::default(), | ||||||
|                 context_type: crate::execution::ContextType::Mock, |                 context_type: crate::execution::ContextType::Mock, | ||||||
|             }; |             }; | ||||||
|  | |||||||
| @ -1217,7 +1217,7 @@ impl Node<CallExpressionKw> { | |||||||
|             ctx.clone(), |             ctx.clone(), | ||||||
|             exec_state.mod_local.pipe_value.clone().map(|v| Arg::new(v, callsite)), |             exec_state.mod_local.pipe_value.clone().map(|v| Arg::new(v, callsite)), | ||||||
|         ); |         ); | ||||||
|         match ctx.stdlib.get_either(fn_name) { |         match ctx.stdlib.read().await.get_either(fn_name) { | ||||||
|             FunctionKind::Core(func) => { |             FunctionKind::Core(func) => { | ||||||
|                 if func.deprecated() { |                 if func.deprecated() { | ||||||
|                     exec_state.warn(CompilationError::err( |                     exec_state.warn(CompilationError::err( | ||||||
| @ -1369,7 +1369,7 @@ impl Node<CallExpression> { | |||||||
|         } |         } | ||||||
|         let fn_args = fn_args; // remove mutability |         let fn_args = fn_args; // remove mutability | ||||||
|  |  | ||||||
|         match ctx.stdlib.get_either(fn_name) { |         match ctx.stdlib.read().await.get_either(fn_name) { | ||||||
|             FunctionKind::Core(func) => { |             FunctionKind::Core(func) => { | ||||||
|                 if func.deprecated() { |                 if func.deprecated() { | ||||||
|                     exec_state.warn(CompilationError::err( |                     exec_state.warn(CompilationError::err( | ||||||
| @ -2228,7 +2228,7 @@ mod test { | |||||||
|         parsing::ast::types::{DefaultParamVal, Identifier, Parameter}, |         parsing::ast::types::{DefaultParamVal, Identifier, Parameter}, | ||||||
|     }; |     }; | ||||||
|     use std::sync::Arc; |     use std::sync::Arc; | ||||||
|     use tokio::task::JoinSet; |     use tokio::{sync::RwLock, task::JoinSet}; | ||||||
|  |  | ||||||
|     #[tokio::test(flavor = "multi_thread")] |     #[tokio::test(flavor = "multi_thread")] | ||||||
|     async fn test_assign_args_to_params() { |     async fn test_assign_args_to_params() { | ||||||
| @ -2347,7 +2347,7 @@ mod test { | |||||||
|                     crate::engine::conn_mock::EngineConnection::new().await.unwrap(), |                     crate::engine::conn_mock::EngineConnection::new().await.unwrap(), | ||||||
|                 )), |                 )), | ||||||
|                 fs: Arc::new(crate::fs::FileManager::new()), |                 fs: Arc::new(crate::fs::FileManager::new()), | ||||||
|                 stdlib: Arc::new(crate::std::StdLib::new()), |                 stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())), | ||||||
|                 settings: Default::default(), |                 settings: Default::default(), | ||||||
|                 context_type: ContextType::Mock, |                 context_type: ContextType::Mock, | ||||||
|             }; |             }; | ||||||
| @ -2487,7 +2487,7 @@ import 'a.kcl' | |||||||
|                     .unwrap(), |                     .unwrap(), | ||||||
|             )), |             )), | ||||||
|             fs: Arc::new(crate::fs::FileManager::new()), |             fs: Arc::new(crate::fs::FileManager::new()), | ||||||
|             stdlib: Arc::new(crate::std::StdLib::new()), |             stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())), | ||||||
|             settings: Default::default(), |             settings: Default::default(), | ||||||
|             context_type: ContextType::Mock, |             context_type: ContextType::Mock, | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -27,6 +27,7 @@ pub use memory::EnvironmentRef; | |||||||
| use schemars::JsonSchema; | use schemars::JsonSchema; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| pub use state::{ExecState, MetaSettings}; | pub use state::{ExecState, MetaSettings}; | ||||||
|  | use tokio::sync::RwLock; | ||||||
|  |  | ||||||
| use crate::{ | use crate::{ | ||||||
|     engine::EngineManager, |     engine::EngineManager, | ||||||
| @ -256,7 +257,7 @@ pub enum ContextType { | |||||||
| pub struct ExecutorContext { | pub struct ExecutorContext { | ||||||
|     pub engine: Arc<Box<dyn EngineManager>>, |     pub engine: Arc<Box<dyn EngineManager>>, | ||||||
|     pub fs: Arc<FileManager>, |     pub fs: Arc<FileManager>, | ||||||
|     pub stdlib: Arc<StdLib>, |     pub stdlib: Arc<RwLock<StdLib>>, | ||||||
|     pub settings: ExecutorSettings, |     pub settings: ExecutorSettings, | ||||||
|     pub context_type: ContextType, |     pub context_type: ContextType, | ||||||
| } | } | ||||||
| @ -401,7 +402,7 @@ impl ExecutorContext { | |||||||
|         Ok(Self { |         Ok(Self { | ||||||
|             engine, |             engine, | ||||||
|             fs: Arc::new(FileManager::new()), |             fs: Arc::new(FileManager::new()), | ||||||
|             stdlib: Arc::new(StdLib::new()), |             stdlib: Arc::new(RwLock::new(StdLib::new())), | ||||||
|             settings, |             settings, | ||||||
|             context_type: ContextType::Live, |             context_type: ContextType::Live, | ||||||
|         }) |         }) | ||||||
| @ -420,7 +421,7 @@ impl ExecutorContext { | |||||||
|                     .map_err(|e| format!("{:?}", e))?, |                     .map_err(|e| format!("{:?}", e))?, | ||||||
|             )), |             )), | ||||||
|             fs: Arc::new(FileManager::new(fs_manager)), |             fs: Arc::new(FileManager::new(fs_manager)), | ||||||
|             stdlib: Arc::new(StdLib::new()), |             stdlib: Arc::new(RwLock::new(StdLib::new())), | ||||||
|             settings, |             settings, | ||||||
|             context_type: ContextType::Live, |             context_type: ContextType::Live, | ||||||
|         }) |         }) | ||||||
| @ -433,7 +434,7 @@ impl ExecutorContext { | |||||||
|                 crate::engine::conn_mock::EngineConnection::new().await.unwrap(), |                 crate::engine::conn_mock::EngineConnection::new().await.unwrap(), | ||||||
|             )), |             )), | ||||||
|             fs: Arc::new(FileManager::new()), |             fs: Arc::new(FileManager::new()), | ||||||
|             stdlib: Arc::new(StdLib::new()), |             stdlib: Arc::new(RwLock::new(StdLib::new())), | ||||||
|             settings: Default::default(), |             settings: Default::default(), | ||||||
|             context_type: ContextType::Mock, |             context_type: ContextType::Mock, | ||||||
|         } |         } | ||||||
| @ -451,7 +452,7 @@ impl ExecutorContext { | |||||||
|                     .map_err(|e| format!("{:?}", e))?, |                     .map_err(|e| format!("{:?}", e))?, | ||||||
|             )), |             )), | ||||||
|             fs: Arc::new(FileManager::new(fs_manager)), |             fs: Arc::new(FileManager::new(fs_manager)), | ||||||
|             stdlib: Arc::new(StdLib::new()), |             stdlib: Arc::new(RwLock::new(StdLib::new())), | ||||||
|             settings, |             settings, | ||||||
|             context_type: ContextType::Mock, |             context_type: ContextType::Mock, | ||||||
|         }) |         }) | ||||||
| @ -462,7 +463,7 @@ impl ExecutorContext { | |||||||
|         ExecutorContext { |         ExecutorContext { | ||||||
|             engine, |             engine, | ||||||
|             fs: Arc::new(FileManager::new()), |             fs: Arc::new(FileManager::new()), | ||||||
|             stdlib: Arc::new(StdLib::new()), |             stdlib: Arc::new(RwLock::new(StdLib::new())), | ||||||
|             settings: Default::default(), |             settings: Default::default(), | ||||||
|             context_type: ContextType::MockCustomForwarded, |             context_type: ContextType::MockCustomForwarded, | ||||||
|         } |         } | ||||||
| @ -978,7 +979,7 @@ pub(crate) async fn parse_execute(code: &str) -> Result<ExecTestResults, KclErro | |||||||
|             })?, |             })?, | ||||||
|         )), |         )), | ||||||
|         fs: Arc::new(crate::fs::FileManager::new()), |         fs: Arc::new(crate::fs::FileManager::new()), | ||||||
|         stdlib: Arc::new(crate::std::StdLib::new()), |         stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())), | ||||||
|         settings: Default::default(), |         settings: Default::default(), | ||||||
|         context_type: ContextType::Mock, |         context_type: ContextType::Mock, | ||||||
|     }; |     }; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user