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.
This commit is contained in:
dotCooCoo
2026-11-23 11:36:23 -08:00
parent f205705617
commit c2967e257e
+5 -2
View File
@@ -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")