fix stdout hangged on (#6715)

This commit is contained in:
WindSoilder
2022-10-16 03:29:29 +08:00
committed by GitHub
parent de77cb0cc4
commit a498234f1d
4 changed files with 139 additions and 101 deletions

View File

@ -62,7 +62,7 @@ fn do_with_semicolon_break_on_failed_external() {
#[test]
#[cfg(not(windows))]
fn ignore_error_not_hang_nushell() {
fn ignore_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;
@ -85,6 +85,31 @@ fn ignore_error_not_hang_nushell() {
})
}
#[test]
#[cfg(not(windows))]
fn ignore_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;
Playground::setup("external with many stdout message", |dirs, sandbox| {
let bytes: usize = 81920;
let mut large_file_body = String::with_capacity(bytes);
for _ in 0..bytes {
large_file_body.push_str("a");
}
sandbox.with_files(vec![FileWithContent("a_large_file.txt", &large_file_body)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
do -i {sh -c "cat a_large_file.txt"} | complete | get stdout
"#
));
assert_eq!(actual.out, large_file_body);
})
}
#[test]
#[cfg(not(windows))]
fn ignore_error_with_both_stdout_stderr_messages_not_hang_nushell() {