From d3e33a78b5c0311b6a01f7a1163e087e6d36c2be Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Thu, 16 May 2024 23:06:43 -0400 Subject: [PATCH] Fix/update tests --- crates/nu-command/tests/commands/do_.rs | 6 +++--- crates/nu-protocol/tests/test_config.rs | 14 +++++++++----- tests/shell/pipeline/commands/external.rs | 7 ------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/nu-command/tests/commands/do_.rs b/crates/nu-command/tests/commands/do_.rs index 5f46b02c17..645421c15f 100644 --- a/crates/nu-command/tests/commands/do_.rs +++ b/crates/nu-command/tests/commands/do_.rs @@ -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, ""); } diff --git a/crates/nu-protocol/tests/test_config.rs b/crates/nu-protocol/tests/test_config.rs index bee944d0a2..f47dda3121 100644 --- a/crates/nu-protocol/tests/test_config.rs +++ b/crates/nu-protocol/tests/test_config.rs @@ -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, diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index ff851a3293..bef58adbc6 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -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| {