Add example tests (nu-plugin-test-support) for plugins in repo (#12281)

# Description

Uses the new `nu-plugin-test-support` crate to test the examples of
commands provided by plugins in the repo.

Also fixed some of the examples to pass.

# User-Facing Changes

- Examples that are more guaranteed to work

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
This commit is contained in:
Devyn Cairns
2024-03-25 19:20:35 -07:00
committed by GitHub
parent efe1c99a3b
commit 2ae4408ced
19 changed files with 139 additions and 6 deletions

View File

@ -61,6 +61,19 @@ impl PluginTest {
&mut self.engine_state
}
/// Make additional command declarations available for use by tests.
///
/// This can be used to pull in commands from `nu-cmd-lang` for example, as required.
pub fn add_decl(
&mut self,
decl: Box<dyn nu_protocol::engine::Command>,
) -> Result<&mut Self, ShellError> {
let mut working_set = StateWorkingSet::new(&self.engine_state);
working_set.add_decl(decl);
self.engine_state.merge_delta(working_set.render())?;
Ok(self)
}
/// Evaluate some Nushell source code with the plugin commands in scope with the given input to
/// the pipeline.
///