diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-05-11 20:20:14 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2020-05-11 22:39:13 +0200 |
commit | 3cccadcf0fbfc7ff4e7dd37299a65bea1cf0eab0 (patch) | |
tree | 58c198d0222b942b8bd1321e1423eaaebd909795 /test_plugin | |
parent | a3f82c3d5ec3caad1d4ec74f49ef11adc45807d6 (diff) |
Change plugin interface to prevent segfaults when unloading plugin (#5210)
Fixes: #3473
Closes: #5193
Diffstat (limited to 'test_plugin')
-rw-r--r-- | test_plugin/Cargo.toml | 1 | ||||
-rw-r--r-- | test_plugin/src/lib.rs | 25 | ||||
-rw-r--r-- | test_plugin/tests/integration_tests.rs | 23 |
3 files changed, 29 insertions, 20 deletions
diff --git a/test_plugin/Cargo.toml b/test_plugin/Cargo.toml index 5dcfb61ed..704cee831 100644 --- a/test_plugin/Cargo.toml +++ b/test_plugin/Cargo.toml @@ -11,4 +11,3 @@ crate-type = ["cdylib"] [dependencies] futures = "0.3.4" deno_core = { path = "../core" } -deno = { path = "../cli" } diff --git a/test_plugin/src/lib.rs b/test_plugin/src/lib.rs index 2304cd65b..37868b310 100644 --- a/test_plugin/src/lib.rs +++ b/test_plugin/src/lib.rs @@ -1,20 +1,17 @@ -extern crate deno_core; -extern crate futures; - -use deno_core::Buf; -use deno_core::CoreIsolate; -use deno_core::Op; -use deno_core::ZeroCopyBuf; +use deno_core::plugin_api::Buf; +use deno_core::plugin_api::Interface; +use deno_core::plugin_api::Op; +use deno_core::plugin_api::ZeroCopyBuf; use futures::future::FutureExt; #[no_mangle] -pub fn deno_plugin_init(isolate: &mut CoreIsolate) { - isolate.register_op("testSync", op_test_sync); - isolate.register_op("testAsync", op_test_async); +pub fn deno_plugin_init(interface: &mut dyn Interface) { + interface.register_op("testSync", op_test_sync); + interface.register_op("testAsync", op_test_async); } -pub fn op_test_sync( - _isolate: &mut CoreIsolate, +fn op_test_sync( + _interface: &mut dyn Interface, data: &[u8], zero_copy: Option<ZeroCopyBuf>, ) -> Op { @@ -31,8 +28,8 @@ pub fn op_test_sync( Op::Sync(result_box) } -pub fn op_test_async( - _isolate: &mut CoreIsolate, +fn op_test_async( + _interface: &mut dyn Interface, data: &[u8], zero_copy: Option<ZeroCopyBuf>, ) -> Op { diff --git a/test_plugin/tests/integration_tests.rs b/test_plugin/tests/integration_tests.rs index 2f61ec9aa..17002fc01 100644 --- a/test_plugin/tests/integration_tests.rs +++ b/test_plugin/tests/integration_tests.rs @@ -1,13 +1,26 @@ // To run this test manually: // cd test_plugin -// ../target/debug/deno --allow-plugin tests/test.js debug +// ../target/debug/deno run --unstable --allow-plugin tests/test.js debug -// TODO(ry) Re-enable this test on windows. It is flaky for an unknown reason. -#![cfg(not(windows))] - -use deno::test_util::*; +use std::path::PathBuf; use std::process::Command; +fn target_dir() -> PathBuf { + let current_exe = std::env::current_exe().unwrap(); + let target_dir = current_exe.parent().unwrap().parent().unwrap(); + println!("target_dir {}", target_dir.display()); + target_dir.into() +} + +fn deno_exe_path() -> PathBuf { + // Something like /Users/rld/src/deno/target/debug/deps/deno + let mut p = target_dir().join("deno"); + if cfg!(windows) { + p.set_extension("exe"); + } + p +} + fn deno_cmd() -> Command { assert!(deno_exe_path().exists()); Command::new(deno_exe_path()) |