fix cache multi-file (#6844)
* updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump kittycad.rs i need this for cli Signed-off-by: Jess Frazelle <github@jessfraz.com> * bump the version so i can fix cli Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
		
							
								
								
									
										24
									
								
								rust/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										24
									
								
								rust/Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -1815,7 +1815,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-bumper"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "clap",
 | 
			
		||||
@ -1826,7 +1826,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-derive-docs"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "Inflector",
 | 
			
		||||
 "anyhow",
 | 
			
		||||
@ -1845,7 +1845,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-directory-test-macro"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
@ -1854,7 +1854,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-language-server"
 | 
			
		||||
version = "0.2.68"
 | 
			
		||||
version = "0.2.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "clap",
 | 
			
		||||
@ -1875,7 +1875,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-language-server-release"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "clap",
 | 
			
		||||
@ -1895,7 +1895,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-lib"
 | 
			
		||||
version = "0.2.68"
 | 
			
		||||
version = "0.2.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "approx 0.5.1",
 | 
			
		||||
@ -1970,7 +1970,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-python-bindings"
 | 
			
		||||
version = "0.3.68"
 | 
			
		||||
version = "0.3.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "kcl-lib",
 | 
			
		||||
@ -1985,7 +1985,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-test-server"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "hyper 0.14.32",
 | 
			
		||||
@ -1998,7 +1998,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-to-core"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "async-trait",
 | 
			
		||||
@ -2012,7 +2012,7 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kcl-wasm-lib"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "bson",
 | 
			
		||||
@ -2042,9 +2042,9 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "kittycad"
 | 
			
		||||
version = "0.3.36"
 | 
			
		||||
version = "0.3.37"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0a345fd2a4cb16205f32bd1aa41715045830c59d78c59927fca6580e2a651ac9"
 | 
			
		||||
checksum = "b48a9698d68c791df76aa020b596c324177a614e38ff3dd67eedd04db76e222f"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "async-trait",
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ console_error_panic_hook = "0.1.7"
 | 
			
		||||
dashmap = { version = "6.1.0" }
 | 
			
		||||
http = "1"
 | 
			
		||||
indexmap = "2.9.0"
 | 
			
		||||
kittycad = { version = "0.3.36", default-features = false, features = ["js", "requests"] }
 | 
			
		||||
kittycad = { version = "0.3.37", default-features = false, features = ["js", "requests"] }
 | 
			
		||||
kittycad-modeling-cmds = { version = "0.2.117", features = ["ts-rs", "websocket"] }
 | 
			
		||||
lazy_static = "1.5.0"
 | 
			
		||||
miette = "7.5.0"
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-bumper"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-api"
 | 
			
		||||
rust-version = "1.76"
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-derive-docs"
 | 
			
		||||
description = "A tool for generating documentation from Rust derive macros"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-app"
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-directory-test-macro"
 | 
			
		||||
description = "A tool for generating tests from a directory of kcl files"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-app"
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-language-server-release"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
 | 
			
		||||
publish = false
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
name = "kcl-language-server"
 | 
			
		||||
description = "A language server for KCL."
 | 
			
		||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
 | 
			
		||||
version = "0.2.68"
 | 
			
		||||
version = "0.2.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-lib"
 | 
			
		||||
description = "KittyCAD Language implementation and tools"
 | 
			
		||||
version = "0.2.68"
 | 
			
		||||
version = "0.2.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-app"
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
use kcl_lib::{bust_cache, ExecError, ExecOutcome};
 | 
			
		||||
use kcmc::{each_cmd as mcmd, ModelingCmd};
 | 
			
		||||
use kittycad_modeling_cmds as kcmc;
 | 
			
		||||
use pretty_assertions::assert_eq;
 | 
			
		||||
 | 
			
		||||
#[derive(Debug)]
 | 
			
		||||
struct Variation<'a> {
 | 
			
		||||
@ -247,8 +248,11 @@ extrude(profile001, length = 100)"#
 | 
			
		||||
    )
 | 
			
		||||
    .await;
 | 
			
		||||
 | 
			
		||||
    result.first().unwrap();
 | 
			
		||||
    result.last().unwrap();
 | 
			
		||||
    let first = result.first().unwrap();
 | 
			
		||||
    let last = result.last().unwrap();
 | 
			
		||||
 | 
			
		||||
    assert!(first.1 == last.1, "The images should be the same");
 | 
			
		||||
    assert_eq!(first.2, last.2, "The outcomes should be the same");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "artifact-graph")]
 | 
			
		||||
@ -550,3 +554,64 @@ extrude(profile001, length = 100)
 | 
			
		||||
        "The outcomes artifact graphs should be different"
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[tokio::test(flavor = "multi_thread")]
 | 
			
		||||
async fn kcl_test_cache_multi_file_same_code_dont_reexecute_settings_only_change() {
 | 
			
		||||
    let code = r#"import "toBeImported.kcl" as importedCube
 | 
			
		||||
 | 
			
		||||
importedCube
 | 
			
		||||
 | 
			
		||||
sketch001 = startSketchOn(XZ)
 | 
			
		||||
profile001 = startProfile(sketch001, at = [-134.53, -56.17])
 | 
			
		||||
  |> angledLine(angle = 0, length = 79.05, tag = $rectangleSegmentA001)
 | 
			
		||||
  |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 76.28)
 | 
			
		||||
  |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $seg01)
 | 
			
		||||
  |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02)
 | 
			
		||||
  |> close()
 | 
			
		||||
extrude001 = extrude(profile001, length = 100)
 | 
			
		||||
sketch003 = startSketchOn(extrude001, face = seg02)
 | 
			
		||||
sketch002 = startSketchOn(extrude001, face = seg01)
 | 
			
		||||
"#;
 | 
			
		||||
 | 
			
		||||
    let other_file = (
 | 
			
		||||
        std::path::PathBuf::from("toBeImported.kcl"),
 | 
			
		||||
        r#"sketch001 = startSketchOn(XZ)
 | 
			
		||||
profile001 = startProfile(sketch001, at = [281.54, 305.81])
 | 
			
		||||
  |> angledLine(angle = 0, length = 123.43, tag = $rectangleSegmentA001)
 | 
			
		||||
  |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 85.99)
 | 
			
		||||
  |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
 | 
			
		||||
  |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
 | 
			
		||||
  |> close()
 | 
			
		||||
extrude(profile001, length = 100)"#
 | 
			
		||||
            .to_string(),
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    let result = cache_test(
 | 
			
		||||
        "multi_file_same_code_dont_reexecute_settings_only_change",
 | 
			
		||||
        vec![
 | 
			
		||||
            Variation {
 | 
			
		||||
                code,
 | 
			
		||||
                other_files: vec![other_file.clone()],
 | 
			
		||||
                settings: &kcl_lib::ExecutorSettings {
 | 
			
		||||
                    show_grid: false,
 | 
			
		||||
                    ..Default::default()
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
            Variation {
 | 
			
		||||
                code,
 | 
			
		||||
                other_files: vec![other_file],
 | 
			
		||||
                settings: &kcl_lib::ExecutorSettings {
 | 
			
		||||
                    show_grid: true,
 | 
			
		||||
                    ..Default::default()
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
        ],
 | 
			
		||||
    )
 | 
			
		||||
    .await;
 | 
			
		||||
 | 
			
		||||
    let first = result.first().unwrap();
 | 
			
		||||
    let last = result.last().unwrap();
 | 
			
		||||
 | 
			
		||||
    assert!(first.1 != last.1, "The images should be different for the grid");
 | 
			
		||||
    assert_eq!(first.2, last.2, "The outcomes should be the same");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 35 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 109 KiB  | 
@ -559,7 +559,7 @@ impl From<KclError> for pyo3::PyErr {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// An error which occurred during parsing, etc.
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS)]
 | 
			
		||||
#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS, PartialEq, Eq)]
 | 
			
		||||
#[ts(export)]
 | 
			
		||||
pub struct CompilationError {
 | 
			
		||||
    #[serde(rename = "sourceRange")]
 | 
			
		||||
 | 
			
		||||
@ -118,7 +118,6 @@ pub(super) async fn get_changed_program(old: CacheInformation<'_>, new: CacheInf
 | 
			
		||||
        // We know they have the same imports because the ast is the same.
 | 
			
		||||
        // If we have no imports, we can skip this.
 | 
			
		||||
        if !old.ast.has_import_statements() {
 | 
			
		||||
            println!("No imports, no need to check.");
 | 
			
		||||
            return CacheResult::NoAction(reapply_settings);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -64,7 +64,7 @@ pub mod typed_path;
 | 
			
		||||
pub(crate) mod types;
 | 
			
		||||
 | 
			
		||||
/// Outcome of executing a program.  This is used in TS.
 | 
			
		||||
#[derive(Debug, Clone, Serialize, ts_rs::TS)]
 | 
			
		||||
#[derive(Debug, Clone, Serialize, ts_rs::TS, PartialEq)]
 | 
			
		||||
#[ts(export)]
 | 
			
		||||
#[serde(rename_all = "camelCase")]
 | 
			
		||||
pub struct ExecOutcome {
 | 
			
		||||
@ -385,6 +385,7 @@ impl ExecutorContext {
 | 
			
		||||
        let (ws, _headers) = client
 | 
			
		||||
            .modeling()
 | 
			
		||||
            .commands_ws(
 | 
			
		||||
                None,
 | 
			
		||||
                None,
 | 
			
		||||
                None,
 | 
			
		||||
                if settings.enable_ssao {
 | 
			
		||||
@ -653,14 +654,22 @@ impl ExecutorContext {
 | 
			
		||||
                        keys.sort();
 | 
			
		||||
                        for key in keys {
 | 
			
		||||
                            let (_, id, _, _) = &new_universe[key];
 | 
			
		||||
                            let old_source = old_state.get_source(*id);
 | 
			
		||||
                            let new_source = new_exec_state.get_source(*id);
 | 
			
		||||
                            if old_source != new_source {
 | 
			
		||||
                                clear_scene = true;
 | 
			
		||||
                                break;
 | 
			
		||||
                            if let (Some(source0), Some(source1)) =
 | 
			
		||||
                                (old_state.get_source(*id), new_exec_state.get_source(*id))
 | 
			
		||||
                            {
 | 
			
		||||
                                if source0.source != source1.source {
 | 
			
		||||
                                    clear_scene = true;
 | 
			
		||||
                                    break;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        if !clear_scene {
 | 
			
		||||
                            // Return early we don't need to clear the scene.
 | 
			
		||||
                            let outcome = old_state.to_exec_outcome(result_env).await;
 | 
			
		||||
                            return Ok(outcome);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        (
 | 
			
		||||
                            clear_scene,
 | 
			
		||||
                            crate::Program {
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-python-bindings"
 | 
			
		||||
version = "0.3.68"
 | 
			
		||||
version = "0.3.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
repository = "https://github.com/kittycad/modeling-app"
 | 
			
		||||
exclude = ["tests/*", "files/*", "venv/*"]
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-test-server"
 | 
			
		||||
description = "A test server for KCL"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-to-core"
 | 
			
		||||
description = "Utility methods to convert kcl to engine core executable tests"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
license = "MIT"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-app"
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "kcl-wasm-lib"
 | 
			
		||||
version = "0.1.68"
 | 
			
		||||
version = "0.1.69"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
repository = "https://github.com/KittyCAD/modeling-app"
 | 
			
		||||
rust-version = "1.83"
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user