Merge branch 'main' into pierremtb/issue1349

This commit is contained in:
Pierre Jacquier
2024-03-27 05:20:27 -04:00
parent d7e2abad20
commit d03a641d6f
208 changed files with 10097 additions and 276 deletions

View File

@ -1,3 +1,3 @@
[codespell] [codespell]
ignore-words-list: crate,everytime,inout,co-ordinate,ot,nwo,absolutey ignore-words-list: crate,everytime,inout,co-ordinate,ot,nwo,absolutey
skip: **/target,node_modules,build,**/Cargo.lock,./src-tauri/gen/schemas skip: **/target,node_modules,build,**/Cargo.lock,./docs/kcl/*.md,./src-tauri/gen/schemas

View File

@ -12,6 +12,10 @@ Computes the absolute value of a number.
abs(num: number) -> number abs(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the arccosine of a number (in radians).
acos(num: number) -> number acos(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the arcsine of a number (in radians).
asin(num: number) -> number asin(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the arctangent of a number (in radians).
atan(num: number) -> number atan(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the smallest integer greater than or equal to a number.
ceil(num: number) -> number ceil(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the sine of a number (in radians).
cos(num: number) -> number cos(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Return the value of Eulers number `e`.
e() -> number e() -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the largest integer less than or equal to a number.
floor(num: number) -> number floor(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

180
docs/kcl/getEdge.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

308
docs/kcl/helix.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,10 +30,12 @@ layout: manual
* [`extrude`](kcl/extrude) * [`extrude`](kcl/extrude)
* [`fillet`](kcl/fillet) * [`fillet`](kcl/fillet)
* [`floor`](kcl/floor) * [`floor`](kcl/floor)
* [`getEdge`](kcl/getEdge)
* [`getExtrudeWallTransform`](kcl/getExtrudeWallTransform) * [`getExtrudeWallTransform`](kcl/getExtrudeWallTransform)
* [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge) * [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge)
* [`getOppositeEdge`](kcl/getOppositeEdge) * [`getOppositeEdge`](kcl/getOppositeEdge)
* [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge) * [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge)
* [`helix`](kcl/helix)
* [`hole`](kcl/hole) * [`hole`](kcl/hole)
* [`import`](kcl/import) * [`import`](kcl/import)
* [`lastSegX`](kcl/lastSegX) * [`lastSegX`](kcl/lastSegX)
@ -55,6 +57,7 @@ layout: manual
* [`patternLinear3d`](kcl/patternLinear3d) * [`patternLinear3d`](kcl/patternLinear3d)
* [`pi`](kcl/pi) * [`pi`](kcl/pi)
* [`pow`](kcl/pow) * [`pow`](kcl/pow)
* [`revolve`](kcl/revolve)
* [`segAng`](kcl/segAng) * [`segAng`](kcl/segAng)
* [`segEndX`](kcl/segEndX) * [`segEndX`](kcl/segEndX)
* [`segEndY`](kcl/segEndY) * [`segEndY`](kcl/segEndY)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Returns the angle of the given leg for x.
legAngX(hypotenuse: number, leg: number) -> number legAngX(hypotenuse: number, leg: number) -> number
``` ```
### Tags
* `utilities`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Returns the angle of the given leg for y.
legAngY(hypotenuse: number, leg: number) -> number legAngY(hypotenuse: number, leg: number) -> number
``` ```
### Tags
* `utilities`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Returns the length of the given leg.
legLen(hypotenuse: number, leg: number) -> number legLen(hypotenuse: number, leg: number) -> number
``` ```
### Tags
* `utilities`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the natural logarithm of the number.
ln(num: number) -> number ln(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ The result might not be correctly rounded owing to implementation details; `log2
log(num: number, base: number) -> number log(num: number, base: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the base 10 logarithm of the number.
log10(num: number) -> number log10(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the base 2 logarithm of the number.
log2(num: number) -> number log2(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the maximum of the given arguments.
max(args: [number]) -> number max(args: [number]) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the minimum of the given arguments.
min(args: [number]) -> number min(args: [number]) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Return the value of `pi`. Archimedes constant (π).
pi() -> number pi() -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the number to a power.
pow(num: number, pow: number) -> number pow(num: number, pow: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

412
docs/kcl/revolve.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Computes the sine of a number (in radians).
sin(num: number) -> number sin(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Computes the square root of a number.
sqrt(num: number) -> number sqrt(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,10 @@ Computes the tangent of a number (in radians).
tan(num: number) -> number tan(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,10 @@ Return the value of `tau`. The full circle constant (τ). Equal to 2π.
tau() -> number tau() -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Converts a number from radians to degrees.
toDegrees(num: number) -> number toDegrees(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

View File

@ -12,6 +12,10 @@ Converts a number from degrees to radians.
toRadians(num: number) -> number toRadians(num: number) -> number
``` ```
### Tags
* `math`
### Examples ### Examples
```js ```js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -1,6 +1,6 @@
{ {
"name": "untitled-app", "name": "untitled-app",
"version": "0.16.0", "version": "0.17.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@codemirror/autocomplete": "^6.15.0", "@codemirror/autocomplete": "^6.15.0",
@ -10,7 +10,7 @@
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.18", "@headlessui/react": "^1.7.18",
"@headlessui/tailwindcss": "^0.2.0", "@headlessui/tailwindcss": "^0.2.0",
"@kittycad/lib": "^0.1.0", "@kittycad/lib": "^0.0.56",
"@lezer/javascript": "^1.4.9", "@lezer/javascript": "^1.4.9",
"@open-rpc/client-js": "^1.8.1", "@open-rpc/client-js": "^1.8.1",
"@react-hook/resize-observer": "^1.2.6", "@react-hook/resize-observer": "^1.2.6",

View File

@ -56,8 +56,11 @@
"identifier": "http:default", "identifier": "http:default",
"allow": [ "allow": [
"https://dev.kittycad.io/*", "https://dev.kittycad.io/*",
"https://dev.zoo.dev/*",
"https://kittycad.io/*", "https://kittycad.io/*",
"https://api.dev.kittycad.io/*" "https://zoo.dev/*",
"https://api.dev.kittycad.io/*",
"https://api.dev.zoo.dev/*"
] ]
}, },
"os:allow-platform", "os:allow-platform",

View File

@ -48,12 +48,12 @@
"shortDescription": "", "shortDescription": "",
"targets": "all" "targets": "all"
}, },
"identifier": "io.kittycad.modeling-app", "identifier": "dev.zoo.modeling-app",
"plugins": { "plugins": {
"shell": { "shell": {
"open": true "open": true
} }
}, },
"productName": "zoo-modeling-app", "productName": "zoo-modeling-app",
"version": "0.16.0" "version": "0.17.0"
} }

View File

@ -242,7 +242,6 @@ export const ModelingMachineProvider = ({
} }
exportFromEngine({ exportFromEngine({
source_unit: baseUnit,
format: format as Models['OutputFormat_type'], format: format as Models['OutputFormat_type'],
}).catch((e) => toast.error('Error while exporting', e)) // TODO I think we need to throw the error from engineCommandManager }).catch((e) => toast.error('Error while exporting', e)) // TODO I think we need to throw the error from engineCommandManager
}, },

View File

@ -1289,40 +1289,14 @@ export class EngineCommandManager {
this.callbacksEngineStateConnection.push(callback) this.callbacksEngineStateConnection.push(callback)
} }
endSession() { endSession() {
// TODO: instead of sending a single command with `object_ids: Object.keys(this.artifactMap)` const deleteCmd: EngineCommand = {
// we need to loop over them each individually because if the engine doesn't recognise a single type: 'modeling_cmd_req',
// id the whole command fails. cmd_id: uuidv4(),
const artifactsToDelete: any = {} cmd: {
Object.entries(this.artifactMap).forEach(([id, artifact]) => { type: 'scene_clear_all',
const artifactTypesToDelete: ArtifactMap[string]['commandType'][] = [ },
// 'start_path' creates a new scene object for the path, which is why it needs to be deleted, }
// however all of the segments in the path are its children so there don't need to be deleted. this.engineConnection?.send(deleteCmd)
// this fact is very opaque in the api and docs (as to what should can be deleted).
// Using an array is the list is likely to grow.
'start_path',
'entity_linear_pattern',
'entity_circular_pattern',
]
if (artifactTypesToDelete.includes(artifact.commandType)) {
artifactsToDelete[id] = artifact
}
if (artifact.commandType === 'import_files') {
// TODO why is this handled differently from other artifacts, i.e. why does it not use the id from the
// modeling command? We're having to do special clean up for this one special object.
artifactsToDelete[(artifact as any)?.data?.data?.object_id] = artifact
}
})
Object.keys(artifactsToDelete).forEach((id) => {
const deleteCmd: EngineCommand = {
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: {
type: 'remove_scene_objects',
object_ids: [id],
},
}
this.engineConnection?.send(deleteCmd)
})
} }
addCommandLog(message: CommandLog) { addCommandLog(message: CommandLog) {
if (this._commandLogs.length > 500) { if (this._commandLogs.length > 500) {

View File

@ -127,13 +127,15 @@ export interface ProgramMemory {
export const executor = async ( export const executor = async (
node: Program, node: Program,
programMemory: ProgramMemory = { root: {}, return: null }, programMemory: ProgramMemory = { root: {}, return: null },
engineCommandManager: EngineCommandManager engineCommandManager: EngineCommandManager,
isMock: boolean = false
): Promise<ProgramMemory> => { ): Promise<ProgramMemory> => {
engineCommandManager.startNewSession() engineCommandManager.startNewSession()
const _programMemory = await _executor( const _programMemory = await _executor(
node, node,
programMemory, programMemory,
engineCommandManager engineCommandManager,
isMock
) )
await engineCommandManager.waitForAllCommands() await engineCommandManager.waitForAllCommands()
@ -148,7 +150,8 @@ const getSettingsState = import('components/SettingsAuthProvider').then(
export const _executor = async ( export const _executor = async (
node: Program, node: Program,
programMemory: ProgramMemory = { root: {}, return: null }, programMemory: ProgramMemory = { root: {}, return: null },
engineCommandManager: EngineCommandManager engineCommandManager: EngineCommandManager,
isMock: boolean
): Promise<ProgramMemory> => { ): Promise<ProgramMemory> => {
try { try {
const baseUnit = (await getSettingsState)()?.baseUnit || 'mm' const baseUnit = (await getSettingsState)()?.baseUnit || 'mm'
@ -157,7 +160,8 @@ export const _executor = async (
JSON.stringify(programMemory), JSON.stringify(programMemory),
baseUnit, baseUnit,
engineCommandManager, engineCommandManager,
fileSystemManager fileSystemManager,
isMock
) )
return memory return memory
} catch (e: any) { } catch (e: any) {

View File

@ -5,10 +5,8 @@ import { v4 as uuidv4 } from 'uuid'
// Isolating a function to call the engine to export the current scene. // Isolating a function to call the engine to export the current scene.
// Because it has given us trouble in automated testing environments. // Because it has given us trouble in automated testing environments.
export function exportFromEngine({ export function exportFromEngine({
source_unit,
format, format,
}: { }: {
source_unit: Models['UnitLength_type']
format: Models['OutputFormat_type'] format: Models['OutputFormat_type']
}) { }) {
return engineCommandManager.sendSceneCommand({ return engineCommandManager.sendSceneCommand({
@ -20,7 +18,6 @@ export function exportFromEngine({
// in the scene to export. In that case, you'd pass the IDs thru here. // in the scene to export. In that case, you'd pass the IDs thru here.
entity_ids: [], entity_ids: [],
format, format,
source_unit,
}, },
cmd_id: uuidv4(), cmd_id: uuidv4(),
}) })

View File

@ -66,7 +66,7 @@ export async function enginelessExecutor(
}) as any as EngineCommandManager }) as any as EngineCommandManager
await mockEngineCommandManager.waitForReady await mockEngineCommandManager.waitForReady
mockEngineCommandManager.startNewSession() mockEngineCommandManager.startNewSession()
const programMemory = await _executor(ast, pm, mockEngineCommandManager) const programMemory = await _executor(ast, pm, mockEngineCommandManager, true)
await mockEngineCommandManager.waitForAllCommands() await mockEngineCommandManager.waitForAllCommands()
return programMemory return programMemory
} }
@ -86,7 +86,7 @@ export async function executor(
}) })
await engineCommandManager.waitForReady await engineCommandManager.waitForReady
engineCommandManager.startNewSession() engineCommandManager.startNewSession()
const programMemory = await _executor(ast, pm, engineCommandManager) const programMemory = await _executor(ast, pm, engineCommandManager, false)
await engineCommandManager.waitForAllCommands() await engineCommandManager.waitForAllCommands()
return programMemory return programMemory
} }

View File

@ -263,7 +263,7 @@ export async function executeAst({
} }
const programMemory = await (useFakeExecutor const programMemory = await (useFakeExecutor
? enginelessExecutor(ast, programMemoryOverride || programMemoryInit()) ? enginelessExecutor(ast, programMemoryOverride || programMemoryInit())
: _executor(ast, programMemoryInit(), engineCommandManager)) : _executor(ast, programMemoryInit(), engineCommandManager, false))
await engineCommandManager.waitForAllCommands() await engineCommandManager.waitForAllCommands()
return { return {

View File

@ -322,6 +322,12 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
[[package]] [[package]]
name = "base64ct" name = "base64ct"
version = "1.6.0" version = "1.6.0"
@ -1843,9 +1849,11 @@ dependencies = [
"approx 0.5.1", "approx 0.5.1",
"async-recursion", "async-recursion",
"async-trait", "async-trait",
"base64 0.22.0",
"bson", "bson",
"chrono", "chrono",
"clap", "clap",
"convert_case",
"criterion", "criterion",
"dashmap", "dashmap",
"databake", "databake",
@ -1853,6 +1861,7 @@ dependencies = [
"expectorate", "expectorate",
"futures", "futures",
"gltf-json", "gltf-json",
"image",
"insta", "insta",
"itertools 0.12.1", "itertools 0.12.1",
"js-sys", "js-sys",
@ -1874,6 +1883,7 @@ dependencies = [
"tokio-tungstenite", "tokio-tungstenite",
"tower-lsp", "tower-lsp",
"ts-rs", "ts-rs",
"twenty-twenty",
"uuid", "uuid",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -1896,9 +1906,9 @@ dependencies = [
[[package]] [[package]]
name = "kittycad" name = "kittycad"
version = "0.2.62" version = "0.2.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bb6a3e37a902c099f3f077f1e75814339bf5d548151a675544366841a882377" checksum = "93a332250e08fd715ad3d5826e04d36da1c5bb42d0c1b1ff1f0598278b9ebf3c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@ -59,7 +59,7 @@ members = [
] ]
[workspace.dependencies] [workspace.dependencies]
kittycad = { version = "0.2.62", default-features = false, features = ["js", "requests"] } kittycad = { version = "0.2.63", default-features = false, features = ["js", "requests"] }
kittycad-execution-plan = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" } kittycad-execution-plan = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }
kittycad-execution-plan-macros = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" } kittycad-execution-plan-macros = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }
kittycad-execution-plan-traits = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" } kittycad-execution-plan-traits = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }

View File

@ -201,7 +201,7 @@ fn do_stdlib_inner(
.code_blocks .code_blocks
.iter() .iter()
.enumerate() .enumerate()
.map(|(index, code_block)| generate_code_block_test(&fn_name_str, code_block, index)) .map(|(index, code_block)| generate_code_block_test(&fn_name_str, code_block, index, &metadata.tags))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let tags = metadata let tags = metadata
@ -731,12 +731,18 @@ fn parse_array_type(type_name: &str) -> Option<(&str, usize)> {
// For each kcl code block, we want to generate a test that checks that the // For each kcl code block, we want to generate a test that checks that the
// code block is valid kcl code and compiles and executes. // code block is valid kcl code and compiles and executes.
fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> proc_macro2::TokenStream { fn generate_code_block_test(
fn_name: &str,
code_block: &str,
index: usize,
tags: &[String],
) -> 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_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
// to show easy imports. // to show easy imports.
let ignored = if fn_name == "import" { let ignored = if tags.contains(&"norun".to_string()) {
quote! { #[ignore] } quote! { #[ignore] }
} else { } else {
quote! {} quote! {}
@ -778,14 +784,58 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new(crate::engine::conn::EngineConnection::new(ws).await.unwrap())), let ctx = crate::executor::ExecutorContext::new(ws, units.clone()).await.unwrap();
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx).await.unwrap(); crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx).await.unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D { x: 0.0, y: 0.0, z: 0.0 },
up: kittycad::types::Point3D { x: 0.0, y: 0.0, z: 1.0 },
vantage: kittycad::types::Point3D { x: 0.0, y: -x, z: y },
sequence: None,
},
)
.await.unwrap();
// Send a snapshot request to the engine.
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await.unwrap();
// Create a temporary file to write the output to.
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
// Save the snapshot locally.
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
// Read the output file.
let actual = image::io::Reader::open(output_file).unwrap().decode().unwrap();
twenty_twenty::assert_image(&format!("tests/outputs/{}.png", #test_name_str), &actual, 1.0);
} }
} }
} }

View File

@ -345,6 +345,7 @@ fn test_stdlib_doc_comment_with_code_on_ignored_function() {
let (item, errors) = do_stdlib( let (item, errors) = do_stdlib(
quote! { quote! {
name = "import", name = "import",
tags = ["norun"]
}, },
quote! { quote! {
/// This is some function. /// This is some function.

View File

@ -29,19 +29,72 @@ mod test_examples_show {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
&actual,
1.0,
);
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
@ -73,19 +126,72 @@ mod test_examples_show {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_show1"),
&actual,
1.0,
);
} }
} }

View File

@ -29,19 +29,72 @@ mod test_examples_show {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
&actual,
1.0,
);
} }
} }

View File

@ -29,19 +29,72 @@ mod test_examples_my_func {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_my_func0"),
&actual,
1.0,
);
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
@ -73,19 +126,72 @@ mod test_examples_my_func {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_my_func1"),
&actual,
1.0,
);
} }
} }

View File

@ -30,19 +30,72 @@ mod test_examples_import {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
&actual,
1.0,
);
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
@ -75,19 +128,72 @@ mod test_examples_import {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_import1"),
&actual,
1.0,
);
} }
} }
@ -126,7 +232,7 @@ impl crate::docs::StdLibFn for Import {
} }
fn tags(&self) -> Vec<String> { fn tags(&self) -> Vec<String> {
vec![] vec!["norun".to_string()]
} }
fn args(&self) -> Vec<crate::docs::StdLibFnArg> { fn args(&self) -> Vec<crate::docs::StdLibFnArg> {

View File

@ -29,19 +29,72 @@ mod test_examples_line_to {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_line_to0"),
&actual,
1.0,
);
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
@ -73,19 +126,72 @@ mod test_examples_line_to {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_line_to1"),
&actual,
1.0,
);
} }
} }

View File

@ -29,19 +29,72 @@ mod test_examples_min {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_min0"),
&actual,
1.0,
);
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
@ -73,19 +126,72 @@ mod test_examples_min {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_min1"),
&actual,
1.0,
);
} }
} }

View File

@ -29,19 +29,72 @@ mod test_examples_show {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
&actual,
1.0,
);
} }
} }

View File

@ -1,7 +1,6 @@
#[cfg(test)] #[cfg(test)]
mod test_examples_import { mod test_examples_import {
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
#[ignore]
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"),);
let http_client = reqwest::Client::builder() let http_client = reqwest::Client::builder()
@ -30,19 +29,72 @@ mod test_examples_import {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
&actual,
1.0,
);
} }
} }

View File

@ -1,7 +1,6 @@
#[cfg(test)] #[cfg(test)]
mod test_examples_import { mod test_examples_import {
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
#[ignore]
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"),);
let http_client = reqwest::Client::builder() let http_client = reqwest::Client::builder()
@ -30,19 +29,72 @@ mod test_examples_import {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
&actual,
1.0,
);
} }
} }

View File

@ -1,7 +1,6 @@
#[cfg(test)] #[cfg(test)]
mod test_examples_import { mod test_examples_import {
#[tokio::test(flavor = "multi_thread", worker_threads = 5)] #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
#[ignore]
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"),);
let http_client = reqwest::Client::builder() let http_client = reqwest::Client::builder()
@ -30,19 +29,72 @@ mod test_examples_import {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
&actual,
1.0,
);
} }
} }

View File

@ -29,19 +29,72 @@ mod test_examples_show {
let parser = crate::parser::Parser::new(tokens); let parser = crate::parser::Parser::new(tokens);
let program = parser.ast().unwrap(); let program = parser.ast().unwrap();
let mut mem: crate::executor::ProgramMemory = Default::default(); let mut mem: crate::executor::ProgramMemory = Default::default();
let ctx = crate::executor::ExecutorContext { let units = kittycad::types::UnitLength::Mm;
engine: std::sync::Arc::new(Box::new( let ctx = crate::executor::ExecutorContext::new(ws, units.clone())
crate::engine::conn::EngineConnection::new(ws) .await
.await .unwrap();
.unwrap(),
)),
fs: crate::fs::FileManager::new(),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm,
};
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx) crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
.await .await
.unwrap(); .unwrap();
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
ctx.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::DefaultCameraLookAt {
center: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
},
up: kittycad::types::Point3D {
x: 0.0,
y: 0.0,
z: 1.0,
},
vantage: kittycad::types::Point3D {
x: 0.0,
y: -x,
z: y,
},
sequence: None,
},
)
.await
.unwrap();
let resp = ctx
.engine
.send_modeling_cmd(
false,
uuid::Uuid::new_v4(),
crate::executor::SourceRange::default(),
kittycad::types::ModelingCmd::TakeSnapshot {
format: kittycad::types::ImageFormat::Png,
},
)
.await
.unwrap();
let output_file =
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
if let kittycad::types::OkWebSocketResponseData::Modeling {
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
} = &resp
{
std::fs::write(&output_file, &data.contents.0).unwrap();
} else {
panic!("Unexpected response from engine: {:?}", resp);
}
let actual = image::io::Reader::open(output_file)
.unwrap()
.decode()
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
&actual,
1.0,
);
} }
} }

View File

@ -67,12 +67,16 @@ debug = true
debug = true # Flamegraphs of benchmarks require accurate debug symbols debug = true # Flamegraphs of benchmarks require accurate debug symbols
[dev-dependencies] [dev-dependencies]
base64 = "0.22.0"
convert_case = "0.6.0"
criterion = "0.5.1" criterion = "0.5.1"
expectorate = "1.1.0" expectorate = "1.1.0"
image = "0.24.9"
insta = { version = "1.36.1", features = ["json"] } insta = { version = "1.36.1", features = ["json"] }
itertools = "0.12.1" itertools = "0.12.1"
pretty_assertions = "1.4.0" pretty_assertions = "1.4.0"
tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros", "time"] } tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros", "time"] }
twenty-twenty = "0.7.0"
[[bench]] [[bench]]
name = "compiler_benchmark" name = "compiler_benchmark"

View File

@ -134,6 +134,11 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
pub fn is_cmd_with_return_values(cmd: &kittycad::types::ModelingCmd) -> bool { pub fn is_cmd_with_return_values(cmd: &kittycad::types::ModelingCmd) -> bool {
let (kittycad::types::ModelingCmd::Export { .. } let (kittycad::types::ModelingCmd::Export { .. }
| kittycad::types::ModelingCmd::Extrude { .. } | kittycad::types::ModelingCmd::Extrude { .. }
| kittycad::types::ModelingCmd::DefaultCameraLookAt { .. }
| kittycad::types::ModelingCmd::DefaultCameraFocusOn { .. }
| kittycad::types::ModelingCmd::DefaultCameraGetSettings { .. }
| kittycad::types::ModelingCmd::DefaultCameraPerspectiveSettings { .. }
| kittycad::types::ModelingCmd::DefaultCameraZoom { .. }
| kittycad::types::ModelingCmd::SketchModeDisable { .. } | kittycad::types::ModelingCmd::SketchModeDisable { .. }
| kittycad::types::ModelingCmd::ObjectBringToFront { .. } | kittycad::types::ModelingCmd::ObjectBringToFront { .. }
| kittycad::types::ModelingCmd::SelectWithPoint { .. } | kittycad::types::ModelingCmd::SelectWithPoint { .. }
@ -144,8 +149,6 @@ pub fn is_cmd_with_return_values(cmd: &kittycad::types::ModelingCmd) -> bool {
| kittycad::types::ModelingCmd::EntityGetAllChildUuids { .. } | kittycad::types::ModelingCmd::EntityGetAllChildUuids { .. }
| kittycad::types::ModelingCmd::CameraDragMove { .. } | kittycad::types::ModelingCmd::CameraDragMove { .. }
| kittycad::types::ModelingCmd::CameraDragEnd { .. } | kittycad::types::ModelingCmd::CameraDragEnd { .. }
| kittycad::types::ModelingCmd::DefaultCameraGetSettings { .. }
| kittycad::types::ModelingCmd::DefaultCameraZoom { .. }
| kittycad::types::ModelingCmd::SelectGet { .. } | kittycad::types::ModelingCmd::SelectGet { .. }
| kittycad::types::ModelingCmd::Solid3DGetAllEdgeFaces { .. } | kittycad::types::ModelingCmd::Solid3DGetAllEdgeFaces { .. }
| kittycad::types::ModelingCmd::Solid3DGetAllOppositeEdges { .. } | kittycad::types::ModelingCmd::Solid3DGetAllOppositeEdges { .. }

View File

@ -983,11 +983,13 @@ pub struct ExecutorContext {
pub fs: FileManager, pub fs: FileManager,
pub stdlib: Arc<StdLib>, pub stdlib: Arc<StdLib>,
pub units: kittycad::types::UnitLength, pub units: kittycad::types::UnitLength,
/// Mock mode is only for the modeling app when they just want to mock engine calls and not
/// actually make them.
pub is_mock: bool,
} }
impl ExecutorContext { impl ExecutorContext {
/// Create a new default executor context. /// Create a new default executor context.
#[cfg(not(test))]
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub async fn new(ws: reqwest::Upgraded, units: kittycad::types::UnitLength) -> Result<Self> { pub async fn new(ws: reqwest::Upgraded, units: kittycad::types::UnitLength) -> Result<Self> {
Ok(Self { Ok(Self {
@ -995,6 +997,7 @@ impl ExecutorContext {
fs: FileManager::new(), fs: FileManager::new(),
stdlib: Arc::new(StdLib::new()), stdlib: Arc::new(StdLib::new()),
units, units,
is_mock: false,
}) })
} }
} }
@ -1302,6 +1305,7 @@ mod tests {
fs: crate::fs::FileManager::new(), fs: crate::fs::FileManager::new(),
stdlib: Arc::new(crate::std::StdLib::new()), stdlib: Arc::new(crate::std::StdLib::new()),
units: kittycad::types::UnitLength::Mm, units: kittycad::types::UnitLength::Mm,
is_mock: false,
}; };
let memory = execute(program, &mut mem, BodyType::Root, &ctx).await?; let memory = execute(program, &mut mem, BodyType::Root, &ctx).await?;

Some files were not shown because too many files have changed in this diff Show More