mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-23 23:09:42 +00:00
Isolate smol::Command hang as a test, does not hang
This commit is contained in:
parent
e5481e2e65
commit
92c4552146
2 changed files with 27 additions and 1 deletions
|
@ -11,4 +11,5 @@ anyhow = { version = "1.0", features = ["std"] }
|
|||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
bincode = "1.3"
|
||||
pollster = "0.2.5"
|
||||
pollster = "0.2.5"
|
||||
smol = "1.2.5"
|
||||
|
|
|
@ -19,6 +19,7 @@ mod tests {
|
|||
and_back: WasiFn<u32, u32>,
|
||||
imports: WasiFn<u32, u32>,
|
||||
half_async: WasiFn<u32, u32>,
|
||||
echo_async: WasiFn<String, String>,
|
||||
}
|
||||
|
||||
async {
|
||||
|
@ -34,6 +35,22 @@ mod tests {
|
|||
.unwrap()
|
||||
.host_function_async("import_half", |a: u32| async move { a / 2 })
|
||||
.unwrap()
|
||||
.host_function_async("command_async", |command: String| async move {
|
||||
// TODO: actual thing
|
||||
dbg!(&command);
|
||||
let mut args = command.split(' ');
|
||||
let command = args.next().unwrap();
|
||||
smol::process::Command::new(command)
|
||||
.args(args)
|
||||
.output()
|
||||
.await
|
||||
.ok()
|
||||
.map(|output| {
|
||||
dbg!("Did run command!");
|
||||
output.stdout
|
||||
})
|
||||
})
|
||||
.unwrap()
|
||||
.init(include_bytes!("../../../plugins/bin/test_plugin.wasm"))
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -49,6 +66,7 @@ mod tests {
|
|||
and_back: runtime.function("and_back").unwrap(),
|
||||
imports: runtime.function("imports").unwrap(),
|
||||
half_async: runtime.function("half_async").unwrap(),
|
||||
echo_async: runtime.function("echo_async").unwrap(),
|
||||
};
|
||||
|
||||
let unsorted = vec![1, 3, 4, 2, 5];
|
||||
|
@ -64,6 +82,13 @@ mod tests {
|
|||
assert_eq!(runtime.call(&plugin.and_back, 1).await.unwrap(), 8);
|
||||
assert_eq!(runtime.call(&plugin.imports, 1).await.unwrap(), 8);
|
||||
assert_eq!(runtime.call(&plugin.half_async, 4).await.unwrap(), 2);
|
||||
assert_eq!(
|
||||
runtime
|
||||
.call(&plugin.echo_async, "eko".into())
|
||||
.await
|
||||
.unwrap(),
|
||||
"eko\n"
|
||||
);
|
||||
|
||||
// dbg!("{}", runtime.call(&plugin.and_back, 1).await.unwrap());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue