Added let command to PluginTest (#12431)

# Description
The `let` command is needed for many example tests. This pull request
adds the `let` command to the EngineState of Test Plugin.

cc: @devyn 

# User-Facing Changes
No user changes. Plugin tests can now have examples with the let
keyword.

Co-authored-by: Jack Wright <jack.wright@disqo.com>
This commit is contained in:
Jack Wright 2024-04-06 13:11:41 -07:00 committed by GitHub
parent fe99729cdb
commit 1c5bd21ebc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 0 deletions

1
Cargo.lock generated
View File

@ -3060,6 +3060,7 @@ name = "nu-plugin-test-support"
version = "0.92.2"
dependencies = [
"nu-ansi-term",
"nu-cmd-lang",
"nu-engine",
"nu-parser",
"nu-plugin",

View File

@ -13,6 +13,7 @@ nu-engine = { path = "../nu-engine", version = "0.92.2", features = ["plugin"] }
nu-protocol = { path = "../nu-protocol", version = "0.92.2", features = ["plugin"] }
nu-parser = { path = "../nu-parser", version = "0.92.2", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.92.2" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.92.2" }
nu-ansi-term = { workspace = true }
similar = "2.4"

View File

@ -1,6 +1,7 @@
use std::{cmp::Ordering, convert::Infallible, sync::Arc};
use nu_ansi_term::Style;
use nu_cmd_lang::Let;
use nu_engine::eval_block;
use nu_parser::parse;
use nu_plugin::{Plugin, PluginCommand, PluginCustomValue, PluginSource};
@ -38,6 +39,7 @@ impl PluginTest {
) -> Result<PluginTest, ShellError> {
let mut engine_state = EngineState::new();
let mut working_set = StateWorkingSet::new(&engine_state);
working_set.add_decl(Box::new(Let));
let reg_plugin = fake_register(&mut working_set, name, plugin)?;
let source = Arc::new(PluginSource::new(reg_plugin));