Fix pipeline stall in do during capture and remove excessive redirections (#7204)

Currently, if you run `do -i { sudo apt upgrade }`, stdin gets swallowed
and doesn't let you respond yes/no to the upgrade question. This PR
fixes that, but runs into https://github.com/nushell/nushell/issues/7205
so the tests fail.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
This commit is contained in:
Alex Saveau
2023-01-24 21:24:38 -08:00
committed by GitHub
parent d64e381085
commit 5cbaabeeab
3 changed files with 72 additions and 23 deletions

View File

@ -100,7 +100,7 @@ fn ignore_error_should_work_for_external_command() {
#[test]
#[cfg(not(windows))]
fn ignore_error_with_too_much_stderr_not_hang_nushell() {
fn capture_error_with_too_much_stderr_not_hang_nushell() {
use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::pipeline;
use nu_test_support::playground::Playground;
@ -115,8 +115,8 @@ fn ignore_error_with_too_much_stderr_not_hang_nushell() {
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
do -i {sh -c "cat a_large_file.txt 1>&2"} | complete | get stderr
"#
do -c {sh -c "cat a_large_file.txt 1>&2"} | complete | get stderr
"#,
));
assert_eq!(actual.out, large_file_body);
@ -125,7 +125,7 @@ fn ignore_error_with_too_much_stderr_not_hang_nushell() {
#[test]
#[cfg(not(windows))]
fn ignore_error_with_too_much_stdout_not_hang_nushell() {
fn capture_error_with_too_much_stdout_not_hang_nushell() {
use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::pipeline;
use nu_test_support::playground::Playground;
@ -140,8 +140,8 @@ fn ignore_error_with_too_much_stdout_not_hang_nushell() {
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
do -i {sh -c "cat a_large_file.txt"} | complete | get stdout
"#
do -c {sh -c "cat a_large_file.txt"} | complete | get stdout
"#,
));
assert_eq!(actual.out, large_file_body);
@ -150,7 +150,7 @@ fn ignore_error_with_too_much_stdout_not_hang_nushell() {
#[test]
#[cfg(not(windows))]
fn ignore_error_with_both_stdout_stderr_messages_not_hang_nushell() {
fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() {
use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::playground::Playground;
Playground::setup(
@ -172,16 +172,16 @@ fn ignore_error_with_both_stdout_stderr_messages_not_hang_nushell() {
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
do -i {bash test.sh} | complete | get stdout | str trim
"#
do -c {bash test.sh} | complete | get stdout | str trim
"#,
));
assert_eq!(actual.out, expect_body);
// check for stderr
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
do -i {bash test.sh} | complete | get stderr | str trim
"#
do -c {bash test.sh} | complete | get stderr | str trim
"#,
));
assert_eq!(actual.out, expect_body);
},

View File

@ -95,7 +95,8 @@ fn save_stderr_and_stdout_to_same_file() {
r#"
let-env FOO = "bar";
let-env BAZ = "ZZZ";
do -i {nu -c 'nu --testbin echo_env FOO; nu --testbin echo_env_stderr BAZ'} | save -r save_test_5/new-file.txt --stderr save_test_5/new-file.txt"#,
do -c {nu -c 'nu --testbin echo_env FOO; nu --testbin echo_env_stderr BAZ'} | save -r save_test_5/new-file.txt --stderr save_test_5/new-file.txt
"#,
);
let actual = file_contents(expected_file);
@ -118,7 +119,8 @@ fn save_stderr_and_stdout_to_diff_file() {
r#"
let-env FOO = "bar";
let-env BAZ = "ZZZ";
do -i {nu -c 'nu --testbin echo_env FOO; nu --testbin echo_env_stderr BAZ'} | save -r save_test_6/log.txt --stderr save_test_6/err.txt"#,
do -c {nu -c 'nu --testbin echo_env FOO; nu --testbin echo_env_stderr BAZ'} | save -r save_test_6/log.txt --stderr save_test_6/err.txt
"#,
);
let actual = file_contents(expected_file);