Fix mixed units assemblies to work, regardless of project settings (#5818)

* Add mixed units test

* Add incorrect output

* Change to always set units since old units are not accurate

* Update output after fix
This commit is contained in:
Jonathan Tran
2025-03-17 11:26:56 -04:00
committed by GitHub
parent a8b0e1a771
commit dc82b4c8ea
31 changed files with 1727 additions and 273 deletions

View File

@ -55,10 +55,9 @@ impl ExecutorContext {
for annotation in annotations {
if annotation.name() == Some(annotations::SETTINGS) {
if matches!(body_type, BodyType::Root) {
let old_units = exec_state.length_unit();
exec_state.mod_local.settings.update_from_annotation(annotation)?;
let new_units = exec_state.length_unit();
if !self.engine.execution_kind().await.is_isolated() && old_units != new_units {
if !self.engine.execution_kind().await.is_isolated() {
self.engine
.set_units(new_units.into(), annotation.as_source_range())
.await?;

View File

@ -2224,3 +2224,24 @@ mod crazy_multi_profile {
super::execute(TEST_NAME, true).await
}
}
mod assembly_mixed_units_cubes {
const TEST_NAME: &str = "assembly_mixed_units_cubes";
/// Test parsing KCL.
#[test]
fn parse() {
super::parse(TEST_NAME)
}
/// Test that parsing and unparsing KCL produces the original KCL input.
#[test]
fn unparse() {
super::unparse(TEST_NAME)
}
/// Test that KCL is executed correctly.
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_execute() {
super::execute(TEST_NAME, true).await
}
}