run-external spreads command if it's a list (#15776)

This commit is contained in:
Firegem
2025-05-18 04:09:32 -04:00
committed by GitHub
parent 5483519c7d
commit 1e8876b076
2 changed files with 43 additions and 3 deletions

View File

@ -535,3 +535,32 @@ fn can_run_ps1_files(prefix: &str) {
assert!(actual.out.contains("Hello World"));
});
}
#[rstest]
#[case("^")]
#[case("run-external ")]
fn expand_command_if_list(#[case] prefix: &str) {
use nu_test_support::fs::Stub::FileWithContent;
Playground::setup("expand command if list", |dirs, sandbox| {
sandbox.with_files(&[FileWithContent("foo.txt", "Hello World")]);
let actual = nu!(
cwd: dirs.test(),
r#"
let cmd = [nu `--testbin`]; {}$cmd meow foo.txt
"#,
prefix
);
assert!(actual.out.contains("Hello World"));
})
}
#[rstest]
#[case("^")]
#[case("run-external ")]
fn error_when_command_list_empty(#[case] prefix: &str) {
Playground::setup("error when command is list with no items", |dirs, _| {
let actual = nu!(cwd: dirs.test(), "let cmd = []; {}$cmd", prefix);
assert!(actual.err.contains("missing parameter"));
})
}