From 79182db587dd3adb8b0327b18ea1f4b2610dcc37 Mon Sep 17 00:00:00 2001 From: Reilly Wood <26268125+rgwood@users.noreply.github.com> Date: Tue, 29 Mar 2022 04:10:43 -0700 Subject: [PATCH] Clean up which/which-support Cargo feature (#5019) * Rename "which" feature to "which-support" * Ignore currently broken environment tests --- Cargo.toml | 4 ++-- crates/nu-command/src/core_commands/version.rs | 2 +- crates/nu-command/src/default_context.rs | 2 +- crates/nu-command/src/system/which_.rs | 8 ++++---- crates/nu-command/tests/commands/mod.rs | 2 +- tests/shell/environment/env.rs | 14 ++++++++++++++ tests/shell/environment/mod.rs | 4 +++- tests/shell/pipeline/commands/external.rs | 6 +++--- tests/shell/pipeline/commands/internal.rs | 2 +- 9 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc1c4366e5..aba9687f14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,13 +74,13 @@ embed-resource = "1" [features] plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin"] -default = ["plugin", "which", "zip-support", "trash-support"] +default = ["plugin", "which-support", "zip-support", "trash-support"] stable = ["default"] extra = ["default", "dataframe"] wasi = [] # Stable (Default) -which = ["nu-command/which"] +which-support = ["nu-command/which"] zip-support = ["nu-command/zip"] trash-support = ["nu-command/trash-support"] diff --git a/crates/nu-command/src/core_commands/version.rs b/crates/nu-command/src/core_commands/version.rs index d7d74f90a9..af464e8b55 100644 --- a/crates/nu-command/src/core_commands/version.rs +++ b/crates/nu-command/src/core_commands/version.rs @@ -256,7 +256,7 @@ fn features_enabled() -> Vec { names.push("uuid".to_string()); } - #[cfg(feature = "which")] + #[cfg(feature = "which-support")] { names.push("which".to_string()); } diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 201b047c68..831dc0e649 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -142,7 +142,7 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { Sys, }; - #[cfg(feature = "which")] + #[cfg(feature = "which-support")] bind_command! { Which }; // Strings diff --git a/crates/nu-command/src/system/which_.rs b/crates/nu-command/src/system/which_.rs index 146823e3c4..a05a600a45 100644 --- a/crates/nu-command/src/system/which_.rs +++ b/crates/nu-command/src/system/which_.rs @@ -128,7 +128,7 @@ fn get_entries_in_nu( all_entries } -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] fn get_first_entry_in_path( item: &str, span: Span, @@ -140,7 +140,7 @@ fn get_first_entry_in_path( .ok() } -#[cfg(not(feature = "which"))] +#[cfg(not(feature = "which-support"))] fn get_first_entry_in_path( _item: &str, _span: Span, @@ -150,7 +150,7 @@ fn get_first_entry_in_path( None } -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] fn get_all_entries_in_path( item: &str, span: Span, @@ -165,7 +165,7 @@ fn get_all_entries_in_path( .unwrap_or_default() } -#[cfg(not(feature = "which"))] +#[cfg(not(feature = "which-support"))] fn get_all_entries_in_path( _item: &str, _span: Span, diff --git a/crates/nu-command/tests/commands/mod.rs b/crates/nu-command/tests/commands/mod.rs index 7f1052d213..3fa25a45e3 100644 --- a/crates/nu-command/tests/commands/mod.rs +++ b/crates/nu-command/tests/commands/mod.rs @@ -66,7 +66,7 @@ mod update; mod upsert; mod use_; mod where_; -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] mod which; mod with_env; mod wrap; diff --git a/tests/shell/environment/env.rs b/tests/shell/environment/env.rs index 2d2cb51fed..f7b0736870 100644 --- a/tests/shell/environment/env.rs +++ b/tests/shell/environment/env.rs @@ -14,6 +14,8 @@ fn env_shorthand() { assert_eq!(actual.out, "bar"); } +// FIXME: shorthand breaks when there's an equals sign in the env var +#[ignore] #[test] fn env_shorthand_with_equals() { let actual = nu!(cwd: ".", r#" @@ -22,6 +24,8 @@ fn env_shorthand_with_equals() { assert_eq!(actual.out, "my_module=info"); } +// FIXME: shorthand breaks when there's an equals sign in the env var +#[ignore] #[test] fn env_shorthand_with_comma_equals() { let actual = nu!(cwd: ".", r#" @@ -30,6 +34,8 @@ fn env_shorthand_with_comma_equals() { assert_eq!(actual.out, "info,my_module=info"); } +// FIXME: shorthand breaks when there's an equals sign in the env var +#[ignore] #[test] fn env_shorthand_with_comma_colons_equals() { let actual = nu!(cwd: ".", r#" @@ -38,6 +44,8 @@ fn env_shorthand_with_comma_colons_equals() { assert_eq!(actual.out, "info,my_module=info,lib_crate::lib_mod=trace"); } +// FIXME: shorthand breaks when there's an equals sign in the env var +#[ignore] #[test] fn env_shorthand_multi_second_with_comma_colons_equals() { let actual = nu!(cwd: ".", r#" @@ -49,6 +57,8 @@ fn env_shorthand_multi_second_with_comma_colons_equals() { ); } +// FIXME: shorthand breaks when there's an equals sign in the env var +#[ignore] #[test] fn env_shorthand_multi_first_with_comma_colons_equals() { let actual = nu!(cwd: ".", r#" @@ -68,6 +78,8 @@ fn env_shorthand_multi() { assert_eq!(actual.out, "barbaz"); } +// FIXME: for some reason Nu is attempting to execute foo in `let-env FOO = foo` +#[ignore] #[test] fn passes_let_env_env_var_to_external_process() { let actual = nu!(cwd: ".", r#" @@ -85,6 +97,8 @@ fn passes_with_env_env_var_to_external_process() { assert_eq!(actual.out, "foo"); } +// FIXME: autoenv not currently implemented +#[ignore] #[test] #[serial] fn passes_env_from_local_cfg_to_external_process() { diff --git a/tests/shell/environment/mod.rs b/tests/shell/environment/mod.rs index e35eff939e..062488c103 100644 --- a/tests/shell/environment/mod.rs +++ b/tests/shell/environment/mod.rs @@ -1,5 +1,7 @@ mod env; -mod nu_env; + +// FIXME: nu_env tests depend on autoenv which hasn't been ported yet +// mod nu_env; pub mod support { use nu_test_support::{nu, playground::*, Outcome}; diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index 2951af4589..149e7c24e8 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -1,6 +1,6 @@ use nu_test_support::nu; -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] #[test] fn shows_error_for_command_not_found() { let actual = nu!( @@ -11,7 +11,7 @@ fn shows_error_for_command_not_found() { assert!(!actual.err.is_empty()); } -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] #[test] fn shows_error_for_command_not_found_in_pipeline() { let actual = nu!( @@ -23,7 +23,7 @@ fn shows_error_for_command_not_found_in_pipeline() { } #[ignore] // jt: we can't test this using the -c workaround currently -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] #[test] fn automatically_change_directory() { use nu_test_support::playground::Playground; diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs index 27b1944cf3..f579682503 100644 --- a/tests/shell/pipeline/commands/internal.rs +++ b/tests/shell/pipeline/commands/internal.rs @@ -647,7 +647,7 @@ fn run_dynamic_blocks() { assert_eq!(actual.out, "holaaaa"); } -#[cfg(feature = "which")] +#[cfg(feature = "which-support")] #[test] fn argument_subexpression_reports_errors() { let actual = nu!(