mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
fix(nu-command/tests): further remove unnecessary pipeline() and cwd() (#8793)
# Description This PR further fixes tests as part of #8670 # User-Facing Changes None # Tests + Formatting None # After Submitting None --------- Signed-off-by: Harshal Chaudhari <harshal.chaudhary@gmail.com> Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
This commit is contained in:
committed by
GitHub
parent
1c5846e1fb
commit
35e8420780
@ -1,13 +1,10 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use nu_test_support::nu;
|
||||
#[cfg(not(windows))]
|
||||
use nu_test_support::pipeline;
|
||||
|
||||
#[test]
|
||||
fn capture_errors_works() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
do -c {$env.use}
|
||||
"#
|
||||
));
|
||||
let actual = nu!("do -c {$env.use}");
|
||||
|
||||
eprintln!("actual.err: {:?}", actual.err);
|
||||
|
||||
@ -16,60 +13,35 @@ fn capture_errors_works() {
|
||||
|
||||
#[test]
|
||||
fn capture_errors_works_for_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
do -c {nu --testbin fail}
|
||||
"#
|
||||
));
|
||||
let actual = nu!("do -c {nu --testbin fail}");
|
||||
assert!(actual.err.contains("External command 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`
|
||||
"#
|
||||
));
|
||||
let actual = nu!("do -c {nu --testbin fail} | echo `text`");
|
||||
assert!(actual.err.contains("External command 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`
|
||||
"#
|
||||
));
|
||||
let actual = nu!(r#"do -c {nu --testbin fail}; echo `text`"#);
|
||||
assert!(actual.err.contains("External command failed"));
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn do_with_semicolon_break_on_failed_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
do { nu --not_exist_flag }; `text`
|
||||
"#
|
||||
));
|
||||
let actual = nu!(r#"do { nu --not_exist_flag }; `text`"#);
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_shell_errors_works_for_external_with_semicolon() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
do -s { open asdfasdf.txt }; "text"
|
||||
"#
|
||||
));
|
||||
let actual = nu!(r#"do -s { open asdfasdf.txt }; "text""#);
|
||||
|
||||
assert_eq!(actual.err, "");
|
||||
assert_eq!(actual.out, "text");
|
||||
@ -77,12 +49,7 @@ fn ignore_shell_errors_works_for_external_with_semicolon() {
|
||||
|
||||
#[test]
|
||||
fn ignore_program_errors_works_for_external_with_semicolon() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
do -p { nu -c 'exit 1' }; "text"
|
||||
"#
|
||||
));
|
||||
let actual = nu!(r#"do -p { nu -c 'exit 1' }; "text""#);
|
||||
|
||||
assert_eq!(actual.err, "");
|
||||
assert_eq!(actual.out, "text");
|
||||
@ -90,9 +57,7 @@ fn ignore_program_errors_works_for_external_with_semicolon() {
|
||||
|
||||
#[test]
|
||||
fn ignore_error_should_work_for_external_command() {
|
||||
let actual = nu!(cwd: ".", pipeline(
|
||||
r#"do -i { nu --testbin fail asdf }; echo post"#
|
||||
));
|
||||
let actual = nu!(r#"do -i { nu --testbin fail asdf }; echo post"#);
|
||||
|
||||
assert_eq!(actual.err, "");
|
||||
assert_eq!(actual.out, "post");
|
||||
@ -190,6 +155,6 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() {
|
||||
|
||||
#[test]
|
||||
fn ignore_error_works_with_list_stream() {
|
||||
let actual = nu!(cwd: ".", pipeline(r#"do -i { ["a", $nothing, "b"] | ansi strip }"#));
|
||||
let actual = nu!(r#"do -i { ["a", $nothing, "b"] | ansi strip }"#);
|
||||
assert!(actual.err.is_empty());
|
||||
}
|
||||
|
Reference in New Issue
Block a user