mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:15:42 +02:00
fix(overlay use): report errors in export-env (#16184)
- fixes #10242 # Tests + Formatting Added 2 tests to confirm `use` and `overlay use` report errors in `export-env` blocks. --------- Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
This commit is contained in:
@ -158,7 +158,7 @@ impl Command for OverlayUse {
|
||||
}
|
||||
|
||||
let eval_block = get_eval_block(engine_state);
|
||||
let _ = eval_block(engine_state, &mut callee_stack, block, input);
|
||||
let _ = eval_block(engine_state, &mut callee_stack, block, input)?;
|
||||
|
||||
// The export-env block should see the env vars *before* activating this overlay
|
||||
caller_stack.add_overlay(overlay_name);
|
||||
|
@ -354,3 +354,15 @@ fn test_use_with_printing_current_file() {
|
||||
assert_eq!(actual.out, dirs.test().join("mod.nu").to_string_lossy());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn report_errors_in_export_env() {
|
||||
let actual = nu!(r#"
|
||||
module spam {
|
||||
export-env { error make -u {msg: "reported"} }
|
||||
}
|
||||
use spam
|
||||
"#);
|
||||
|
||||
assert!(actual.err.contains("reported"));
|
||||
}
|
||||
|
@ -1606,3 +1606,17 @@ fn test_overlay_use_with_printing_current_file() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn report_errors_in_export_env() {
|
||||
let inp = &[
|
||||
r#"module spam { export-env { error make -u {msg: "reported"} } }"#,
|
||||
"overlay use spam",
|
||||
];
|
||||
|
||||
let actual = nu!(&inp.join("; "));
|
||||
let actual_repl = nu!(nu_repl_code(inp));
|
||||
|
||||
assert!(actual.err.contains("reported"));
|
||||
assert!(actual_repl.err.contains("reported"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user