From c2967e257e95303e53266f8e56b33b3bcef79267 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 11:36:23 -0800 Subject: [PATCH] Tests: short_stack keeps the run's name line as written The first line of $.stack names the running script. The helper now passes it through unchanged instead of reading it as a frame, and its doc comment says so. --- crates/engine/src/tests/script_include.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/tests/script_include.rs b/crates/engine/src/tests/script_include.rs index 167a7740ce..78b0065b46 100644 --- a/crates/engine/src/tests/script_include.rs +++ b/crates/engine/src/tests/script_include.rs @@ -521,12 +521,15 @@ fn script_included_error_has_local_file_and_line() { let _ = std::fs::remove_dir_all(base); } -/// `$.stack`'s text with each frame's file cut to its name: `function@name:line` a line. +/// `$.stack`'s text with each frame's file cut to its name. The first line is the run's name +/// (`[script name]`) and is kept as written; each line after it is `function@name:line`. pub(crate) fn short_stack(stack: &Value) -> String { let stack = stack.as_str().unwrap_or_else(|| panic!("a stack: {stack}")); stack .lines() - .map(|frame| match (frame.split_once('@'), frame.rsplit_once(':')) { + .enumerate() + .map(|(i, frame)| match (frame.split_once('@'), frame.rsplit_once(':')) { + _ if i == 0 => format!("{frame}\n"), (Some((name, _)), Some((place, line))) => { let file = place.split_once('@').map_or(place, |(_, f)| f).rsplit(['/', '\\']).next().unwrap_or_default(); format!("{name}@{file}:{line}\n")