mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 05:14:44 +02:00
Use nu-cmd-lang default context for plugin tests (#12434)
# Description @ayax79 added `nu-cmd-lang` as a dep for `nu-plugin-test-support` in order to get access to `let`. Since we have the dep anyway now, we might as well just add all of the lang commands - there aren't very many of them and it would be less confusing than only `let` working. # User-Facing Changes - Can use some more core nu language features in plugin tests, like loops and `do` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Might need to change something about the plugin testing section of the book, since I think it says something about there only being the plugin command itself available
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use std::{cmp::Ordering, convert::Infallible, sync::Arc};
|
||||
|
||||
use nu_ansi_term::Style;
|
||||
use nu_cmd_lang::Let;
|
||||
use nu_cmd_lang::create_default_context;
|
||||
use nu_engine::eval_block;
|
||||
use nu_parser::parse;
|
||||
use nu_plugin::{Plugin, PluginCommand, PluginCustomValue, PluginSource};
|
||||
@ -37,9 +37,8 @@ impl PluginTest {
|
||||
name: &str,
|
||||
plugin: Arc<impl Plugin + Send + 'static>,
|
||||
) -> Result<PluginTest, ShellError> {
|
||||
let mut engine_state = EngineState::new();
|
||||
let mut engine_state = create_default_context();
|
||||
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));
|
||||
|
Reference in New Issue
Block a user