mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:16:05 +02:00
source
: make sure the block is compiled when parsing (#15798)
# Description Fixes: https://github.com/nushell/nushell/issues/15749 When sourcing a file, the ir block might be empty because it has been used before, this pr is going to make sure that the ir block is compiled. # User-Facing Changes ``` touch aaa.nu use aaa.nu source aaa.nu ``` Will no longer raise an error. # Tests + Formatting Added 1 test # After Submitting NaN
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use nu_test_support::fs::Stub::{FileWithContent, FileWithContentToBeTrimmed};
|
||||
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent, FileWithContentToBeTrimmed};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::pipeline;
|
||||
use nu_test_support::playground::Playground;
|
||||
@ -334,3 +334,25 @@ fn source_respects_early_return() {
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_after_use_should_not_error() {
|
||||
Playground::setup("source_after_use", |dirs, sandbox| {
|
||||
sandbox.with_files(&[EmptyFile("spam.nu")]);
|
||||
|
||||
let inp = &[r#"use spam.nu"#, r#"source spam.nu"#];
|
||||
let actual = nu!(cwd: dirs.test(), &inp.join("; "));
|
||||
assert!(actual.err.is_empty());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn use_after_source_should_not_error() {
|
||||
Playground::setup("use_after_source", |dirs, sandbox| {
|
||||
sandbox.with_files(&[EmptyFile("spam.nu")]);
|
||||
|
||||
let inp = &[r#"source spam.nu"#, r#"use spam.nu"#];
|
||||
let actual = nu!(cwd: dirs.test(), &inp.join("; "));
|
||||
assert!(actual.err.is_empty());
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user