mirror of
https://github.com/nushell/nushell.git
synced 2025-01-09 15:58:17 +01:00
cf82814606
# Description A slower, gentler alternative to #14531, in that we're just moving one setting *out* of `default_env.nu` in this PR ;-). All this does is transition from using `$env.NU_LIB_DIRS` in the startup config to `const $NU_LIB_DIRS`. Also updates the `sample_env.nu` to reflect the changes. Details: Before: `$env.NU_LIB_DIRS` was unnecessary set both in `main()` and in `default_env.nu` After: `$env.NU_LIB_DIRS` is only set in `main()` Before: `$env.NU_LIB_DIRS` was set to `config-dir/scripts` and `data-dir/completions` After: `$env.NU_LIB_DIRS` is set to an empty list, and `const NU_LIB_DIRS` is set to the directories above Before: Using `--include-path (-I)` would set the `$env.NU_LIB_DIRS` After: Using `--include-path (-I)` sets the constant `$NU_LIB_DIRS` # User-Facing Changes There shouldn't be any breaking changes here. The `$env.NU_LIBS_DIRS` still works for most cases. There are a few areas we need to clean-up to make sure that the const is usable (`nu-check`, et. al.) but they will still work in the meantime with the older `$env` version. # Tests + Formatting * Changed the Type-check on the `$env` version. * Added a type check for the const version. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting Doc updates
40 lines
971 B
Rust
40 lines
971 B
Rust
use crate::repl::tests::{fail_test, run_test, TestResult};
|
|
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn shorthand_env_1() -> TestResult {
|
|
run_test(r#"FOO=BAZ $env.FOO"#, "BAZ")
|
|
}
|
|
|
|
#[test]
|
|
fn shorthand_env_2() -> TestResult {
|
|
fail_test(r#"FOO=BAZ FOO=MOO $env.FOO"#, "defined_twice")
|
|
}
|
|
|
|
#[test]
|
|
fn shorthand_env_3() -> TestResult {
|
|
run_test(r#"FOO=BAZ BAR=MOO $env.FOO"#, "BAZ")
|
|
}
|
|
|
|
#[test]
|
|
fn default_nu_lib_dirs_env_type() {
|
|
// Previously, this was a list<string>
|
|
// While we are transitioning to const NU_LIB_DIRS
|
|
// the env version will be empty, and thus a
|
|
// list<any>
|
|
let actual = nu!("$env.NU_LIB_DIRS | describe");
|
|
assert_eq!(actual.out, "list<any>");
|
|
}
|
|
|
|
#[test]
|
|
fn default_nu_lib_dirs_type() {
|
|
let actual = nu!("$NU_LIB_DIRS | describe");
|
|
assert_eq!(actual.out, "list<string>");
|
|
}
|
|
|
|
#[test]
|
|
fn default_nu_plugin_dirs_type() {
|
|
let actual = nu!("$env.NU_PLUGIN_DIRS | describe");
|
|
assert_eq!(actual.out, "list<string>");
|
|
}
|