Skip to content

Commit 3811c88

Browse files
properly flush batch (#5565)
* properly flush batch Signed-off-by: Jess Frazelle <[email protected]> * add test Signed-off-by: Jess Frazelle <[email protected]> * add test Signed-off-by: Jess Frazelle <[email protected]> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * only flush if not on error Signed-off-by: Jess Frazelle <[email protected]> * better method Signed-off-by: Jess Frazelle <[email protected]> * updates Signed-off-by: Jess Frazelle <[email protected]> * ensure nothing in batch assembly test Signed-off-by: Jess Frazelle <[email protected]> --------- Signed-off-by: Jess Frazelle <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 69a1473 commit 3811c88

File tree

12 files changed

+2585
-2
lines changed

12 files changed

+2585
-2
lines changed

src/wasm-lib/kcl/src/execution/exec_ast.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ impl ExecutorContext {
123123
};
124124
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
125125

126-
if !exec_kind.is_isolated() && new_units != old_units {
126+
// We only need to reset the units if we are not on the Main path.
127+
// If we reset at the end of the main path, then we just add on an extra
128+
// command and we'd need to flush the batch again.
129+
// This avoids that.
130+
if !exec_kind.is_isolated() && new_units != old_units && *path != ModulePath::Main {
127131
self.engine.set_units(old_units.into(), Default::default()).await?;
128132
}
129133
self.engine.replace_execution_kind(original_execution).await;

src/wasm-lib/kcl/src/simulation_tests.rs

+22
Original file line numberDiff line numberDiff line change
@@ -2074,3 +2074,25 @@ mod import_file_parse_error {
20742074
super::execute(TEST_NAME, true).await
20752075
}
20762076
}
2077+
2078+
mod flush_batch_on_end {
2079+
const TEST_NAME: &str = "flush_batch_on_end";
2080+
2081+
/// Test parsing KCL.
2082+
#[test]
2083+
fn parse() {
2084+
super::parse(TEST_NAME);
2085+
}
2086+
2087+
/// Test that parsing and unparsing KCL produces the original KCL input.
2088+
#[test]
2089+
fn unparse() {
2090+
super::unparse(TEST_NAME)
2091+
}
2092+
2093+
/// Test that KCL is executed correctly.
2094+
#[tokio::test(flavor = "multi_thread")]
2095+
async fn kcl_test_execute() {
2096+
super::execute(TEST_NAME, true).await
2097+
}
2098+
}

src/wasm-lib/kcl/tests/cube_with_error/artifact_commands.snap

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: kcl/src/simulation_tests.rs
33
description: Artifact commands cube_with_error.kcl
4-
snapshot_kind: text
54
---
65
[
76
{

0 commit comments

Comments
 (0)