Revert "Add extern for nu command" (#16180)

Reverts nushell/nushell#16119
This commit is contained in:
Bahex
2025-07-15 19:18:44 +03:00
committed by GitHub
parent c4e8e040ce
commit 2df00ff498
12 changed files with 88 additions and 143 deletions

View File

@ -4,14 +4,6 @@ use nu_test_support::playground::Playground;
use rstest::rstest;
use rstest_reuse::*;
// Get full path to nu, so we don't use the nu extern
fn nu_path(prefix: &str) -> String {
let binary = nu_test_support::fs::executable_path()
.to_string_lossy()
.to_string();
format!("{prefix}{}", binary)
}
// Template for run-external test to ensure tests work when calling
// the binary directly, using the caret operator, and when using
// the run-external command
@ -26,8 +18,8 @@ fn run_external_prefixes(#[case] prefix: &str) {}
fn better_empty_redirection(prefix: &str) {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | each {{ |it| {} `--testbin` cococo $it.name }} | ignore",
nu_path(prefix)
"ls | each {{ |it| {}nu `--testbin` cococo $it.name }} | ignore",
prefix
);
eprintln!("out: {}", actual.out);
@ -47,9 +39,9 @@ fn explicit_glob(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo ('*.txt' | into glob)
{}nu `--testbin` cococo ('*.txt' | into glob)
"#,
nu_path(prefix)
prefix
);
assert!(actual.out.contains("D&D_volume_1.txt"));
@ -69,9 +61,9 @@ fn bare_word_expand_path_glob(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
"
{} `--testbin` cococo *.txt
{}nu `--testbin` cococo *.txt
",
nu_path(prefix)
prefix
);
assert!(actual.out.contains("D&D_volume_1.txt"));
@ -91,9 +83,9 @@ fn backtick_expand_path_glob(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo `*.txt`
{}nu `--testbin` cococo `*.txt`
"#,
nu_path(prefix)
prefix
);
assert!(actual.out.contains("D&D_volume_1.txt"));
@ -113,9 +105,9 @@ fn single_quote_does_not_expand_path_glob(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo '*.txt'
{}nu `--testbin` cococo '*.txt'
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "*.txt");
@ -134,9 +126,9 @@ fn double_quote_does_not_expand_path_glob(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo "*.txt"
{}nu `--testbin` cococo "*.txt"
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "*.txt");
@ -149,9 +141,9 @@ fn failed_command_with_semicolon_will_not_execute_following_cmds(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
"
{} `--testbin` fail; echo done
{}nu `--testbin` fail; echo done
",
nu_path(prefix)
prefix
);
assert!(!actual.out.contains("done"));
@ -164,9 +156,9 @@ fn external_args_with_quoted(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo "foo=bar 'hi'"
{}nu `--testbin` cococo "foo=bar 'hi'"
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "foo=bar 'hi'");
@ -206,9 +198,9 @@ fn external_arg_with_non_option_like_embedded_quotes(#[case] prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo foo='bar' 'foo'=bar
{}nu `--testbin` cococo foo='bar' 'foo'=bar
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "foo=bar foo=bar");
@ -225,9 +217,9 @@ fn external_arg_with_string_interpolation(#[case] prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo foo=(2 + 2) $"foo=(2 + 2)" foo=$"(2 + 2)"
{}nu `--testbin` cococo foo=(2 + 2) $"foo=(2 + 2)" foo=$"(2 + 2)"
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "foo=4 foo=4 foo=4");
@ -241,9 +233,9 @@ fn external_arg_with_variable_name(prefix: &str) {
cwd: dirs.test(),
r#"
let dump_command = "PGPASSWORD='db_secret' pg_dump -Fc -h 'db.host' -p '$db.port' -U postgres -d 'db_name' > '/tmp/dump_name'";
{} `--testbin` nonu $dump_command
{}nu `--testbin` nonu $dump_command
"#,
nu_path(prefix)
prefix
);
assert_eq!(
@ -259,9 +251,9 @@ fn external_command_escape_args(prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo "\"abcd"
{}nu `--testbin` cococo "\"abcd"
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, r#""abcd"#);
@ -272,9 +264,9 @@ fn external_command_escape_args(prefix: &str) {
fn external_command_ndots_args(prefix: &str) {
let actual = nu!(
r#"
{} `--testbin` cococo foo/. foo/.. foo/... foo/./bar foo/../bar foo/.../bar ./bar ../bar .../bar
{}nu `--testbin` cococo foo/. foo/.. foo/... foo/./bar foo/../bar foo/.../bar ./bar ../bar .../bar
"#,
nu_path(prefix)
prefix
);
assert_eq!(
@ -294,9 +286,9 @@ fn external_command_ndots_leading_dot_slash(prefix: &str) {
// Don't expand ndots with a leading `./`
let actual = nu!(
r#"
{} `--testbin` cococo ./... ./....
{}nu `--testbin` cococo ./... ./....
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "./... ./....");
@ -308,9 +300,9 @@ fn external_command_url_args(prefix: &str) {
// here
let actual = nu!(
r#"
{} `--testbin` cococo http://example.com http://example.com/.../foo //foo
{}nu `--testbin` cococo http://example.com http://example.com/.../foo //foo
"#,
nu_path(prefix)
prefix
);
assert_eq!(
@ -367,9 +359,9 @@ fn external_arg_expand_tilde(#[case] prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
{} `--testbin` cococo ~/foo ~/(2 + 2)
{}nu `--testbin` cococo ~/foo ~/(2 + 2)
"#,
nu_path(prefix)
prefix
);
let home = dirs::home_dir().expect("failed to find home dir");
@ -390,7 +382,7 @@ fn external_command_not_expand_tilde_with_quotes(prefix: &str) {
Playground::setup(
"external command not expand tilde with quotes",
|dirs, _| {
let actual = nu!(cwd: dirs.test(), r#"{} `--testbin` nonu "~""#, nu_path(prefix));
let actual = nu!(cwd: dirs.test(), r#"{}nu `--testbin` nonu "~""#, prefix);
assert_eq!(actual.out, r#"~"#);
},
)
@ -401,7 +393,7 @@ fn external_command_expand_tilde_with_back_quotes(prefix: &str) {
Playground::setup(
"external command not expand tilde with quotes",
|dirs, _| {
let actual = nu!(cwd: dirs.test(), r#"{} `--testbin` nonu `~`"#, nu_path(prefix));
let actual = nu!(cwd: dirs.test(), r#"{}nu `--testbin` nonu `~`"#, prefix);
assert!(!actual.out.contains('~'));
},
)
@ -412,8 +404,8 @@ fn external_command_receives_raw_binary_data(prefix: &str) {
Playground::setup("external command receives raw binary data", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
"0x[deadbeef] | {} `--testbin` input_bytes_length",
nu_path(prefix)
"0x[deadbeef] | {}nu `--testbin` input_bytes_length",
prefix
);
assert_eq!(actual.out, r#"4"#);
})
@ -502,9 +494,9 @@ fn quotes_trimmed_when_shelling_out(prefix: &str) {
// regression test for a bug where we weren't trimming quotes around string args before shelling out to cmd.exe
let actual = nu!(
r#"
{} `--testbin` cococo "foo"
{}nu `--testbin` cococo "foo"
"#,
nu_path(prefix)
prefix
);
assert_eq!(actual.out, "foo");
@ -573,9 +565,8 @@ fn expand_command_if_list(#[case] prefix: &str) {
let actual = nu!(
cwd: dirs.test(),
r#"
let cmd = ['{}' `--testbin`]; {}$cmd meow foo.txt
let cmd = [nu `--testbin`]; {}$cmd meow foo.txt
"#,
nu_path(""),
prefix
);