Fix/update tests

This commit is contained in:
Ian Manske 2024-05-16 23:06:43 -04:00
parent 69f9bbb4c0
commit d3e33a78b5
3 changed files with 12 additions and 15 deletions

View File

@ -12,21 +12,21 @@ fn capture_errors_works() {
#[test]
fn capture_errors_works_for_external() {
let actual = nu!("do -c {nu --testbin fail}");
assert!(actual.err.contains("External command failed"));
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
}
#[test]
fn capture_errors_works_for_external_with_pipeline() {
let actual = nu!("do -c {nu --testbin fail} | echo `text`");
assert!(actual.err.contains("External command failed"));
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
}
#[test]
fn capture_errors_works_for_external_with_semicolon() {
let actual = nu!(r#"do -c {nu --testbin fail}; echo `text`"#);
assert!(actual.err.contains("External command failed"));
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
}

View File

@ -52,7 +52,7 @@ fn filesize_format_auto_metric_false() {
#[test]
fn fancy_default_errors() {
let actual = nu!(nu_repl_code(&[
let code = nu_repl_code(&[
r#"def force_error [x] {
error make {
msg: "oh no!"
@ -62,8 +62,10 @@ fn fancy_default_errors() {
}
}
}"#,
r#"force_error "My error""#
]));
r#"force_error "My error""#,
]);
let actual = nu!(format!("try {{ {code} }}"));
assert_eq!(
actual.err,
@ -73,7 +75,7 @@ fn fancy_default_errors() {
#[test]
fn narratable_errors() {
let actual = nu!(nu_repl_code(&[
let code = nu_repl_code(&[
r#"$env.config = { error_style: "plain" }"#,
r#"def force_error [x] {
error make {
@ -85,7 +87,9 @@ fn narratable_errors() {
}
}"#,
r#"force_error "my error""#,
]));
]);
let actual = nu!(format!("try {{ {code} }}"));
assert_eq!(
actual.err,

View File

@ -173,13 +173,6 @@ fn basic_outerr_pipe_works(#[case] redirection: &str) {
assert_eq!(actual.out, "7");
}
#[test]
fn err_pipe_with_failed_external_works() {
let actual =
nu!(r#"with-env { FOO: "bar" } { nu --testbin echo_env_stderr_fail FOO e>| str length }"#);
assert_eq!(actual.out, "3");
}
#[test]
fn dont_run_glob_if_pass_variable_to_external() {
Playground::setup("dont_run_glob", |dirs, sandbox| {