summaryrefslogtreecommitdiff
path: root/test_plugin/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test_plugin/tests')
-rw-r--r--test_plugin/tests/integration_tests.rs10
-rw-r--r--test_plugin/tests/test.js26
2 files changed, 22 insertions, 14 deletions
diff --git a/test_plugin/tests/integration_tests.rs b/test_plugin/tests/integration_tests.rs
index 04a032635..fc18d79d9 100644
--- a/test_plugin/tests/integration_tests.rs
+++ b/test_plugin/tests/integration_tests.rs
@@ -1,3 +1,7 @@
+// To run this test manually:
+// cd test_plugin
+// ../target/debug/deno --allow-plugin tests/test.js debug
+
// TODO(ry) Re-enable this test on windows. It is flaky for an unknown reason.
#![cfg(not(windows))]
@@ -38,11 +42,7 @@ fn basic() {
println!("stderr {}", stderr);
}
assert!(output.status.success());
- let expected = if cfg!(target_os = "windows") {
- "Hello from plugin. data: test | zero_copy: test\nPlugin Sync Response: test\r\nHello from plugin. data: test | zero_copy: test\nPlugin Async Response: test\r\n"
- } else {
- "Hello from plugin. data: test | zero_copy: test\nPlugin Sync Response: test\nHello from plugin. data: test | zero_copy: test\nPlugin Async Response: test\n"
- };
+ let expected = "Hello from plugin. data: test | zero_copy: test\nPlugin Sync Response: test\nHello from plugin. data: test | zero_copy: test\nPlugin Async Response: test\n";
assert_eq!(stdout, expected);
assert_eq!(stderr, "");
}
diff --git a/test_plugin/tests/test.js b/test_plugin/tests/test.js
index d34624f09..3661e1078 100644
--- a/test_plugin/tests/test.js
+++ b/test_plugin/tests/test.js
@@ -17,14 +17,21 @@ const filename = `../target/${Deno.args[0]}/${filenamePrefix}${filenameBase}${fi
// in runTestClose() below.
const resourcesPre = Deno.resources();
-const plugin = Deno.openPlugin(filename);
+const rid = Deno.openPlugin(filename);
-const { testSync, testAsync } = plugin.ops;
+const { testSync, testAsync } = Deno.core.ops();
+if (!(testSync > 0)) {
+ throw "bad op id for testSync";
+}
+if (!(testAsync > 0)) {
+ throw "bad op id for testAsync";
+}
const textDecoder = new TextDecoder();
function runTestSync() {
- const response = testSync.dispatch(
+ const response = Deno.core.dispatch(
+ testSync,
new Uint8Array([116, 101, 115, 116]),
new Uint8Array([116, 101, 115, 116])
);
@@ -32,12 +39,13 @@ function runTestSync() {
console.log(`Plugin Sync Response: ${textDecoder.decode(response)}`);
}
-testAsync.setAsyncHandler((response) => {
+Deno.core.setAsyncHandler(testAsync, (response) => {
console.log(`Plugin Async Response: ${textDecoder.decode(response)}`);
});
function runTestAsync() {
- const response = testAsync.dispatch(
+ const response = Deno.core.dispatch(
+ testAsync,
new Uint8Array([116, 101, 115, 116]),
new Uint8Array([116, 101, 115, 116])
);
@@ -50,22 +58,22 @@ function runTestAsync() {
function runTestOpCount() {
const start = Deno.metrics();
- testSync.dispatch(new Uint8Array([116, 101, 115, 116]));
+ Deno.core.dispatch(testSync, new Uint8Array([116, 101, 115, 116]));
const end = Deno.metrics();
- if (end.opsCompleted - start.opsCompleted !== 2) {
+ if (end.opsCompleted - start.opsCompleted !== 1) {
// one op for the plugin and one for Deno.metrics
throw new Error("The opsCompleted metric is not correct!");
}
- if (end.opsDispatched - start.opsDispatched !== 2) {
+ if (end.opsDispatched - start.opsDispatched !== 1) {
// one op for the plugin and one for Deno.metrics
throw new Error("The opsDispatched metric is not correct!");
}
}
function runTestPluginClose() {
- plugin.close();
+ Deno.close(rid);
const resourcesPost = Deno.resources();