Skip to content

Commit

Permalink
fix: plugin ops should change op count metrics (denoland#3455)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored and ry committed Dec 7, 2019
1 parent e02029c commit 7144bbe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/ops/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ pub fn op_open_plugin(
// The inclusion of prefix and rid is designed to avoid any
// op name collision beyond the bound of a single loaded
// plugin instance.
let op_id = registry.register(&format!("plugin_{}_{}", rid, op.0), op.1);
let op_id = registry
.register(&format!("plugin_{}_{}", rid, op.0), state.core_op(op.1));
plugin_resource.ops.insert(op.0, op_id);
}

Expand Down
19 changes: 19 additions & 0 deletions test_plugin/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,24 @@ function runTestAsync() {
}
}

function runTestOpCount() {
const start = Deno.metrics();

testSync.dispatch(new Uint8Array([116, 101, 115, 116]));

const end = Deno.metrics();

if (end.opsCompleted - start.opsCompleted !== 2) {
// 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) {
// one op for the plugin and one for Deno.metrics
throw new Error("The opsDispatched metric is not correct!");
}
}

runTestSync();
runTestAsync();

runTestOpCount();

0 comments on commit 7144bbe

Please sign in to comment.