Skip to content

Commit 7f23cea

Browse files
test(shell): Verify inner function runs before failing
<!-- coderabbit-ai-generated:v1 -->
1 parent 290fe21 commit 7f23cea

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎impl/rust-cli/tests/function_and_script_tests.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ fn test_function_that_fails_pops_its_frame() -> Result<()> {
172172
state.set_positional_params(vec!["outer_arg".to_string()]);
173173

174174
// `inner` fails: the parent of the directory does not exist
175-
let inner_cmd = parse_command("inner() { local X=inner_val; mkdir no/such/parent/dir; }")?;
175+
let inner_cmd =
176+
parse_command("inner() { local X=inner_val; mkdir inner_ran; mkdir no/such/parent/dir; }")?;
176177
inner_cmd.execute(&mut state)?;
177178
let outer_cmd = parse_command("outer() { local X=outer_val; inner inner_arg; }")?;
178179
outer_cmd.execute(&mut state)?;
@@ -182,6 +183,10 @@ fn test_function_that_fails_pops_its_frame() -> Result<()> {
182183

183184
// The error still reaches the caller
184185
assert!(result.is_err(), "the failed mkdir should be an error");
186+
assert!(
187+
temp.path().join("inner_ran").is_dir(),
188+
"inner should create its marker directory before the failing mkdir"
189+
);
185190

186191
// Both frames are gone, and the caller has its own values back
187192
assert_eq!(state.functions.call_depth(), 0);

0 commit comments

Comments
 (0)