Add a test for the plugins

This commit is contained in:
Jonathan Turner 2019-07-04 15:18:19 +12:00
parent c653751d2c
commit dc8545ce10
5 changed files with 12 additions and 23 deletions

View File

@ -69,7 +69,7 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
Ok(jrpc) => match jrpc.params {
Ok(params) => {
let fname = path.to_string_lossy();
println!("Loaded: {} from {}", params.name, fname);
//println!("Loaded: {} from {}", params.name, fname);
if params.is_filter {
let fname = fname.to_string();
context.add_commands(vec![command(
@ -129,12 +129,14 @@ fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
None => println!("PATH is not defined in the environment."),
}
/*
// Also use our debug output for now
let mut path = std::path::PathBuf::from(".");
path.push("target");
path.push("debug");
let _ = load_plugins_in_dir(&path, context);
*/
Ok(())
}

View File

@ -33,17 +33,6 @@ pub enum NuResult {
}
pub fn filter_plugin(path: String, args: CommandArgs) -> Result<OutputStream, ShellError> {
//let mut path = std::path::PathBuf::from(".");
//path.push("target");
//path.push("debug");
//path.push(format!("nu_plugin_{}", plugin_name));
// path = if path.exists() {
// path
// } else {
// std::path::PathBuf::from(format!("nu_plugin_{}", plugin_name))
// };
let mut child = std::process::Command::new(path)
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
@ -130,17 +119,6 @@ pub fn filter_plugin(path: String, args: CommandArgs) -> Result<OutputStream, Sh
}
pub fn sink_plugin(path: String, args: SinkCommandArgs) -> Result<(), ShellError> {
// let mut path = std::path::PathBuf::from(".");
// path.push("target");
// path.push("debug");
// path.push(format!("nu_plugin_{}", plugin_name));
// path = if path.exists() {
// path
// } else {
// std::path::PathBuf::from(format!("nu_plugin_{}", plugin_name))
// };
let mut child = std::process::Command::new(path)
.stdin(std::process::Stdio::piped())
.spawn()

1
tests/inc_plugin.out Normal file
View File

@ -0,0 +1 @@
11

3
tests/inc_plugin.txt Normal file
View File

@ -0,0 +1,3 @@
cd tests
open test.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it
exit

View File

@ -112,4 +112,9 @@ mod tests {
fn unit() {
test_helper("unit");
}
#[test]
fn inc_plugin() {
test_helper("inc_plugin");
}
}