Mock mode tests, ensure mock mode always works for std fns (#2359)
* add generated tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix patterns Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix import Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
2
src/wasm-lib/Cargo.lock
generated
2
src/wasm-lib/Cargo.lock
generated
@ -962,7 +962,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive-docs"
|
name = "derive-docs"
|
||||||
version = "0.1.17"
|
version = "0.1.18"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "derive-docs"
|
name = "derive-docs"
|
||||||
description = "A tool for generating documentation from Rust derive macros"
|
description = "A tool for generating documentation from Rust derive macros"
|
||||||
version = "0.1.17"
|
version = "0.1.18"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/KittyCAD/modeling-app"
|
repository = "https://github.com/KittyCAD/modeling-app"
|
||||||
|
@ -738,6 +738,7 @@ fn generate_code_block_test(
|
|||||||
tags: &[String],
|
tags: &[String],
|
||||||
) -> proc_macro2::TokenStream {
|
) -> proc_macro2::TokenStream {
|
||||||
let test_name = format_ident!("serial_test_example_{}{}", fn_name, index);
|
let test_name = format_ident!("serial_test_example_{}{}", fn_name, index);
|
||||||
|
let test_name_mock = format_ident!("test_mock_example_{}{}", fn_name, index);
|
||||||
let test_name_str = format!("serial_test_example_{}{}", fn_name, index);
|
let test_name_str = format!("serial_test_example_{}{}", fn_name, index);
|
||||||
|
|
||||||
// TODO: We ignore import for now, because the files don't exist and we just want
|
// TODO: We ignore import for now, because the files don't exist and we just want
|
||||||
@ -749,6 +750,23 @@ fn generate_code_block_test(
|
|||||||
};
|
};
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
#ignored
|
||||||
|
async fn #test_name_mock() {
|
||||||
|
let tokens = crate::token::lexer(#code_block).unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
#ignored
|
#ignored
|
||||||
async fn #test_name() {
|
async fn #test_name() {
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_show {
|
mod test_examples_show {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_show0() {
|
||||||
|
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
@ -71,6 +90,25 @@ mod test_examples_show {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_show1() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show1() {
|
async fn serial_test_example_show1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_show {
|
mod test_examples_show {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_show0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_my_func {
|
mod test_examples_my_func {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_my_func0() {
|
||||||
|
let tokens =
|
||||||
|
crate::token::lexer("This is another code block.\nyes sirrr.\nmyFunc").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_my_func0() {
|
async fn serial_test_example_my_func0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
@ -72,6 +92,25 @@ mod test_examples_my_func {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_my_func1() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmyFunc").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_my_func1() {
|
async fn serial_test_example_my_func1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,26 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_import {
|
mod test_examples_import {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
#[ignore]
|
||||||
|
async fn test_mock_example_import0() {
|
||||||
|
let tokens =
|
||||||
|
crate::token::lexer("This is another code block.\nyes sirrr.\nimport").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
@ -73,6 +94,26 @@ mod test_examples_import {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
#[ignore]
|
||||||
|
async fn test_mock_example_import1() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
async fn serial_test_example_import1() {
|
async fn serial_test_example_import1() {
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_line_to {
|
mod test_examples_line_to {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_line_to0() {
|
||||||
|
let tokens =
|
||||||
|
crate::token::lexer("This is another code block.\nyes sirrr.\nlineTo").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_line_to0() {
|
async fn serial_test_example_line_to0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
@ -72,6 +92,25 @@ mod test_examples_line_to {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_line_to1() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nlineTo").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_line_to1() {
|
async fn serial_test_example_line_to1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_min {
|
mod test_examples_min {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_min0() {
|
||||||
|
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nmin").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_min0() {
|
async fn serial_test_example_min0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
@ -71,6 +90,25 @@ mod test_examples_min {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_min1() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmin").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_min1() {
|
async fn serial_test_example_min1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_show {
|
mod test_examples_show {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_show0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_import {
|
mod test_examples_import {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_import0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_import {
|
mod test_examples_import {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_import0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_import {
|
mod test_examples_import {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_import0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_examples_show {
|
mod test_examples_show {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_mock_example_show0() {
|
||||||
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast().unwrap();
|
||||||
|
let ctx = crate::executor::ExecutorContext {
|
||||||
|
engine: std::sync::Arc::new(Box::new(
|
||||||
|
crate::engine::conn_mock::EngineConnection::new()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
)),
|
||||||
|
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
|
||||||
|
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
|
||||||
|
settings: Default::default(),
|
||||||
|
is_mock: true,
|
||||||
|
};
|
||||||
|
ctx.run(program, None).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
@ -19,7 +19,7 @@ chrono = "0.4.38"
|
|||||||
clap = { version = "4.5.4", default-features = false, optional = true }
|
clap = { version = "4.5.4", default-features = false, optional = true }
|
||||||
dashmap = "5.5.3"
|
dashmap = "5.5.3"
|
||||||
databake = { version = "0.1.7", features = ["derive"] }
|
databake = { version = "0.1.7", features = ["derive"] }
|
||||||
derive-docs = { version = "0.1.17", path = "../derive-docs" }
|
derive-docs = { version = "0.1.18", path = "../derive-docs" }
|
||||||
form_urlencoded = "1.2.1"
|
form_urlencoded = "1.2.1"
|
||||||
futures = { version = "0.3.30" }
|
futures = { version = "0.3.30" }
|
||||||
git_rev = "0.1.0"
|
git_rev = "0.1.0"
|
||||||
|
@ -1413,7 +1413,7 @@ mod tests {
|
|||||||
fs: Arc::new(crate::fs::FileManager::new()),
|
fs: Arc::new(crate::fs::FileManager::new()),
|
||||||
stdlib: Arc::new(crate::std::StdLib::new()),
|
stdlib: Arc::new(crate::std::StdLib::new()),
|
||||||
settings: Default::default(),
|
settings: Default::default(),
|
||||||
is_mock: false,
|
is_mock: true,
|
||||||
};
|
};
|
||||||
let memory = ctx.run(program, None).await?;
|
let memory = ctx.run(program, None).await?;
|
||||||
|
|
||||||
|
@ -268,6 +268,14 @@ async fn inner_import(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.ctx.is_mock {
|
||||||
|
return Ok(ImportedGeometry {
|
||||||
|
id: uuid::Uuid::new_v4(),
|
||||||
|
value: import_files.iter().map(|f| f.path.to_string()).collect(),
|
||||||
|
meta: vec![args.source_range.into()],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let id = uuid::Uuid::new_v4();
|
let id = uuid::Uuid::new_v4();
|
||||||
let resp = args
|
let resp = args
|
||||||
.send_modeling_cmd(
|
.send_modeling_cmd(
|
||||||
|
@ -113,6 +113,10 @@ async fn inner_pattern_linear_2d(
|
|||||||
SketchGroupSet::SketchGroups(sketch_groups) => sketch_groups,
|
SketchGroupSet::SketchGroups(sketch_groups) => sketch_groups,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if args.ctx.is_mock {
|
||||||
|
return Ok(starting_sketch_groups);
|
||||||
|
}
|
||||||
|
|
||||||
let mut sketch_groups = Vec::new();
|
let mut sketch_groups = Vec::new();
|
||||||
for sketch_group in starting_sketch_groups.iter() {
|
for sketch_group in starting_sketch_groups.iter() {
|
||||||
let geometries = pattern_linear(
|
let geometries = pattern_linear(
|
||||||
@ -376,6 +380,10 @@ async fn inner_pattern_circular_2d(
|
|||||||
sketch_group: Box<SketchGroup>,
|
sketch_group: Box<SketchGroup>,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<Vec<Box<SketchGroup>>, KclError> {
|
) -> Result<Vec<Box<SketchGroup>>, KclError> {
|
||||||
|
if args.ctx.is_mock {
|
||||||
|
return Ok(vec![sketch_group]);
|
||||||
|
}
|
||||||
|
|
||||||
let geometries = pattern_circular(
|
let geometries = pattern_circular(
|
||||||
CircularPattern::TwoD(data),
|
CircularPattern::TwoD(data),
|
||||||
Geometry::SketchGroup(sketch_group),
|
Geometry::SketchGroup(sketch_group),
|
||||||
@ -424,6 +432,10 @@ async fn inner_pattern_circular_3d(
|
|||||||
extrude_group: Box<ExtrudeGroup>,
|
extrude_group: Box<ExtrudeGroup>,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<Vec<Box<ExtrudeGroup>>, KclError> {
|
) -> Result<Vec<Box<ExtrudeGroup>>, KclError> {
|
||||||
|
if args.ctx.is_mock {
|
||||||
|
return Ok(vec![extrude_group]);
|
||||||
|
}
|
||||||
|
|
||||||
let geometries = pattern_circular(
|
let geometries = pattern_circular(
|
||||||
CircularPattern::ThreeD(data),
|
CircularPattern::ThreeD(data),
|
||||||
Geometry::ExtrudeGroup(extrude_group),
|
Geometry::ExtrudeGroup(extrude_group),
|
||||||
|
Reference in New Issue
Block a user