mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 20:07:51 +02:00
Externals now spawn independently. (#1230)
This commit changes the way we shell out externals when using the `"$it"` argument. Also pipes per row to an external's stdin if no `"$it"` argument is present for external commands. Further separation of logic (preparing the external's command arguments, getting the data for piping, emitting values, spawning processes) will give us a better idea for lower level details regarding external commands until we can find the right abstractions for making them more generic and unify within the pipeline calling logic of Nu internal's and external's.
This commit is contained in:
committed by
GitHub
parent
d29fe6f6de
commit
29431e73c2
@ -1,71 +1 @@
|
||||
mod pipeline {
|
||||
use nu_test_support::{nu, nu_error};
|
||||
|
||||
#[test]
|
||||
fn doesnt_break_on_utf8() {
|
||||
let actual = nu!(cwd: ".", "echo ö");
|
||||
|
||||
assert_eq!(actual, "ö", "'{}' should contain ö", actual);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_process_stdout_of_external_piped_to_stdin_of_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"cococo "nushelll" | chop"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "nushell");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_process_one_row_from_internal_piped_to_stdin_of_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"echo "nushelll" | chop"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "nushell");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shows_error_for_external_command_that_fails() {
|
||||
let actual = nu_error!(
|
||||
cwd: ".",
|
||||
"fail"
|
||||
);
|
||||
|
||||
assert!(actual.contains("External command failed"));
|
||||
}
|
||||
|
||||
mod expands_tilde {
|
||||
use super::nu;
|
||||
|
||||
#[test]
|
||||
fn as_home_directory_when_passed_as_argument_and_begins_with_tilde_to_an_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
cococo ~
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(
|
||||
!actual.contains('~'),
|
||||
format!("'{}' should not contain ~", actual)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_expand_when_passed_as_argument_and_does_not_start_with_tilde_to_an_external() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
cococo "1~1"
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "1~1");
|
||||
}
|
||||
}
|
||||
}
|
||||
mod pipeline;
|
||||
|
Reference in New Issue
Block a user