forked from extern/nushell
Add a test for the plugins
This commit is contained in:
parent
c653751d2c
commit
dc8545ce10
@ -69,7 +69,7 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
|
|||||||
Ok(jrpc) => match jrpc.params {
|
Ok(jrpc) => match jrpc.params {
|
||||||
Ok(params) => {
|
Ok(params) => {
|
||||||
let fname = path.to_string_lossy();
|
let fname = path.to_string_lossy();
|
||||||
println!("Loaded: {} from {}", params.name, fname);
|
//println!("Loaded: {} from {}", params.name, fname);
|
||||||
if params.is_filter {
|
if params.is_filter {
|
||||||
let fname = fname.to_string();
|
let fname = fname.to_string();
|
||||||
context.add_commands(vec![command(
|
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."),
|
None => println!("PATH is not defined in the environment."),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Also use our debug output for now
|
// Also use our debug output for now
|
||||||
let mut path = std::path::PathBuf::from(".");
|
let mut path = std::path::PathBuf::from(".");
|
||||||
path.push("target");
|
path.push("target");
|
||||||
path.push("debug");
|
path.push("debug");
|
||||||
|
|
||||||
let _ = load_plugins_in_dir(&path, context);
|
let _ = load_plugins_in_dir(&path, context);
|
||||||
|
*/
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -33,17 +33,6 @@ pub enum NuResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn filter_plugin(path: String, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
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)
|
let mut child = std::process::Command::new(path)
|
||||||
.stdin(std::process::Stdio::piped())
|
.stdin(std::process::Stdio::piped())
|
||||||
.stdout(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> {
|
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)
|
let mut child = std::process::Command::new(path)
|
||||||
.stdin(std::process::Stdio::piped())
|
.stdin(std::process::Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
|
1
tests/inc_plugin.out
Normal file
1
tests/inc_plugin.out
Normal file
@ -0,0 +1 @@
|
|||||||
|
11
|
3
tests/inc_plugin.txt
Normal file
3
tests/inc_plugin.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cd tests
|
||||||
|
open test.json | get glossary.GlossDiv.GlossList.GlossEntry.Height | inc | echo $it
|
||||||
|
exit
|
@ -112,4 +112,9 @@ mod tests {
|
|||||||
fn unit() {
|
fn unit() {
|
||||||
test_helper("unit");
|
test_helper("unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inc_plugin() {
|
||||||
|
test_helper("inc_plugin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user