summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/bench.rs9
-rw-r--r--cli/tools/test.rs9
2 files changed, 2 insertions, 16 deletions
diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs
index 962b1ac17..5f467bc6e 100644
--- a/cli/tools/bench.rs
+++ b/cli/tools/bench.rs
@@ -489,14 +489,7 @@ async fn bench_specifier(
}))?;
for (desc, function) in benchmarks {
sender.send(BenchEvent::Wait(desc.id))?;
- let promise = {
- let scope = &mut worker.js_runtime.handle_scope();
- let cb = function.open(scope);
- let this = v8::undefined(scope).into();
- let promise = cb.call(scope, this, &[]).unwrap();
- v8::Global::new(scope, promise)
- };
- let result = worker.js_runtime.resolve_value(promise).await?;
+ let result = worker.js_runtime.call_and_await(&function).await?;
let scope = &mut worker.js_runtime.handle_scope();
let result = v8::Local::new(scope, result);
let result = serde_v8::from_v8::<BenchResult>(scope, result)?;
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 268f3b4b9..62a104733 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -997,14 +997,7 @@ pub async fn test_specifier(
}
sender.send(TestEvent::Wait(desc.id))?;
let earlier = SystemTime::now();
- let promise = {
- let scope = &mut worker.js_runtime.handle_scope();
- let cb = function.open(scope);
- let this = v8::undefined(scope).into();
- let promise = cb.call(scope, this, &[]).unwrap();
- v8::Global::new(scope, promise)
- };
- let result = match worker.js_runtime.resolve_value(promise).await {
+ let result = match worker.js_runtime.call_and_await(&function).await {
Ok(r) => r,
Err(error) => {
if error.is::<JsError>() {