mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 00:54:56 +02:00
Move from source
to source-env
(#6277)
* start working on source-env * WIP * Get most tests working, still one to go * Fix file-relative paths; Report parser error * Fix merge conflicts; Restore source as deprecated * Tests: Use source-env; Remove redundant tests * Fmt * Respect hidden env vars * Fix file-relative eval for source-env * Add file-relative eval to "overlay use" * Use FILE_PWD only in source-env and "overlay use" * Ignore new tests for now This will be another issue * Throw an error if setting FILE_PWD manually * Fix source-related test failures * Fix nu-check to respect FILE_PWD * Fix corrupted spans in source-env shell errors * Fix up some references to old source * Remove deprecation message * Re-introduce deleted tests Co-authored-by: kubouch <kubouch@gmail.com>
This commit is contained in:
@ -83,35 +83,6 @@ fn module_private_import_decl_not_public() {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO -- doesn't work because modules are never evaluated
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn module_private_import_env() {
|
||||
Playground::setup("module_private_import_env", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"main.nu",
|
||||
r#"
|
||||
use spam.nu FOO_HELPER
|
||||
|
||||
export def foo [] { $env.FOO_HELPER }
|
||||
"#,
|
||||
)])
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
export env FOO_HELPER { "foo" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &[r#"use main.nu foo"#, r#"foo"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_public_import_decl() {
|
||||
Playground::setup("module_public_import_decl", |dirs, sandbox| {
|
||||
@ -163,33 +134,6 @@ fn module_public_import_alias() {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO -- doesn't work because modules are never evaluated
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn module_public_import_env() {
|
||||
Playground::setup("module_public_import_decl", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"main.nu",
|
||||
r#"
|
||||
export use spam.nu FOO
|
||||
"#,
|
||||
)])
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
export env FOO { "foo" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &[r#"use main.nu FOO"#, r#"$env.FOO"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_nested_imports() {
|
||||
Playground::setup("module_nested_imports", |dirs, sandbox| {
|
||||
@ -347,16 +291,50 @@ fn module_nested_imports_in_dirs_prefixed() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_eval_export_env() {
|
||||
Playground::setup("module_eval_export_env", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
export-env { let-env FOO = 'foo' }
|
||||
"#,
|
||||
)]);
|
||||
fn module_import_env_1() {
|
||||
Playground::setup("module_imprt_env_1", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"main.nu",
|
||||
r#"
|
||||
export-env { source-env spam.nu }
|
||||
|
||||
let inp = &[r#"source spam.nu"#, r#"$env.FOO"#];
|
||||
export def foo [] { $env.FOO_HELPER }
|
||||
"#,
|
||||
)])
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
export-env { let-env FOO_HELPER = "foo" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &[r#"source-env main.nu"#, r#"use main.nu foo"#, r#"foo"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_import_env_2() {
|
||||
Playground::setup("module_import_env_2", |dirs, sandbox| {
|
||||
sandbox
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"main.nu",
|
||||
r#"
|
||||
export-env { source-env spam.nu }
|
||||
"#,
|
||||
)])
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
export-env { let-env FOO = "foo" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &[r#"source-env main.nu"#, r#"$env.FOO"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
|
Reference in New Issue
Block a user