From 1c5bd21ebcdcb86b640af41c31d9d049d7493411 Mon Sep 17 00:00:00 2001 From: Jack Wright <56345+ayax79@users.noreply.github.com> Date: Sat, 6 Apr 2024 13:11:41 -0700 Subject: [PATCH] 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 --- Cargo.lock | 1 + crates/nu-plugin-test-support/Cargo.toml | 1 + crates/nu-plugin-test-support/src/plugin_test.rs | 2 ++ 3 files changed, 4 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 86e8435683..c0bc746f0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/crates/nu-plugin-test-support/Cargo.toml b/crates/nu-plugin-test-support/Cargo.toml index 53159d66e3..a0af1629f7 100644 --- a/crates/nu-plugin-test-support/Cargo.toml +++ b/crates/nu-plugin-test-support/Cargo.toml @@ -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" diff --git a/crates/nu-plugin-test-support/src/plugin_test.rs b/crates/nu-plugin-test-support/src/plugin_test.rs index 42cec9990e..af4a52f4e5 100644 --- a/crates/nu-plugin-test-support/src/plugin_test.rs +++ b/crates/nu-plugin-test-support/src/plugin_test.rs @@ -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 { 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));