mirror of
https://github.com/nushell/nushell.git
synced 2025-04-09 21:28:55 +02:00
Logs and tests (#3247)
* Add command name to err * Add var name to error message * Add test for def comment in test
This commit is contained in:
parent
0fe6c7c558
commit
f03f1949bf
@ -31,7 +31,7 @@ pub(crate) async fn run_external_command(
|
|||||||
if !context.host.lock().is_external_cmd(&command.name) {
|
if !context.host.lock().is_external_cmd(&command.name) {
|
||||||
return Err(ShellError::labeled_error(
|
return Err(ShellError::labeled_error(
|
||||||
"Command not found",
|
"Command not found",
|
||||||
"command not found",
|
format!("command {} not found", &command.name),
|
||||||
&command.name_tag,
|
&command.name_tag,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ fn evaluate_reference(name: &str, ctx: &EvaluationContext, tag: Tag) -> Result<V
|
|||||||
Some(v) => Ok(v),
|
Some(v) => Ok(v),
|
||||||
None => Err(ShellError::labeled_error(
|
None => Err(ShellError::labeled_error(
|
||||||
"Variable not in scope",
|
"Variable not in scope",
|
||||||
"unknown variable",
|
format!("unknown variable: {}", x),
|
||||||
tag.span,
|
tag.span,
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
|
25
crates/nu-parser/tests/main.rs
Normal file
25
crates/nu-parser/tests/main.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use nu_test_support::fs::Stub::FileWithContent;
|
||||||
|
use nu_test_support::nu;
|
||||||
|
use nu_test_support::playground::Playground;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn defs_contain_comment_in_help() {
|
||||||
|
Playground::setup("comment_test", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![FileWithContent(
|
||||||
|
"my_def.nu",
|
||||||
|
r#"
|
||||||
|
# I comment and test. I am a good boy.
|
||||||
|
def comment_philosphy [] {
|
||||||
|
echo It’s not a bug – it’s an undocumented feature. (Anonymous)
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
|
let actual = nu!(cwd: dirs.test(), r#"
|
||||||
|
source my_def.nu
|
||||||
|
help comment_philosphy
|
||||||
|
"#);
|
||||||
|
|
||||||
|
assert!(actual.out.contains("I comment and test. I am a good boy."));
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user