Eval external command result immediately when using do command with -c (#6645)

* make capture error works better in do command

* remove into string test because we have no way to generate Value::Error for now
This commit is contained in:
WindSoilder
2022-09-30 20:14:02 +08:00
committed by GitHub
parent 6f59167960
commit 530ff3893e
3 changed files with 108 additions and 17 deletions

View File

@ -5,11 +5,47 @@ fn capture_errors_works() {
let actual = nu!(
cwd: ".", pipeline(
r#"
do -c {$env.use} | describe
do -c {$env.use}
"#
));
assert_eq!(actual.out, "error");
assert!(actual.err.contains("column_not_found"));
}
#[test]
fn capture_errors_works_for_external() {
let actual = nu!(
cwd: ".", pipeline(
r#"
do -c {nu --testbin fail}
"#
));
assert!(actual.err.contains("External command runs to failed"));
assert_eq!(actual.out, "");
}
#[test]
fn capture_errors_works_for_external_with_pipeline() {
let actual = nu!(
cwd: ".", pipeline(
r#"
do -c {nu --testbin fail} | echo `text`
"#
));
assert!(actual.err.contains("External command runs to failed"));
assert_eq!(actual.out, "");
}
#[test]
fn capture_errors_works_for_external_with_semicolon() {
let actual = nu!(
cwd: ".", pipeline(
r#"
do -c {nu --testbin fail}; echo `text`
"#
));
assert!(actual.err.contains("External command runs to failed"));
assert_eq!(actual.out, "");
}
#[test]

View File

@ -172,18 +172,6 @@ fn from_nothing() {
assert_eq!(actual.out, "");
}
#[test]
fn from_error() {
let actual = nu!(
cwd: ".", pipeline(
r#"
do -c {$env.use} | into string
"#
));
assert_eq!(actual.out, "nu::shell::column_not_found");
}
#[test]
fn int_into_string() {
let actual = nu!(