refactor(test): grab runTests() and runBenchmarks() from __bootstrap (#15420)

This commit is contained in:
Nayeem Rahman 2022-09-02 18:44:45 +01:00 committed by GitHub
parent 5262937285
commit 4f8dea100e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 128 additions and 64 deletions

View file

@ -7,7 +7,6 @@ use deno_core::error::AnyError;
use deno_core::futures::task::LocalFutureObj;
use deno_core::futures::FutureExt;
use deno_core::located_script_name;
use deno_core::serde_json::json;
use deno_core::Extension;
use deno_core::ModuleId;
use deno_graph::source::ResolveResponse;
@ -220,10 +219,7 @@ impl CliMainWorker {
&mut self,
mode: TestMode,
) -> Result<(), AnyError> {
self.worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].enableTestAndBench()"#,
)?;
self.worker.enable_test();
// Enable op call tracing in core to enable better debugging of op sanitizer
// failures.
@ -273,17 +269,10 @@ impl CliMainWorker {
}
self.worker.dispatch_load_event(&located_script_name!())?;
let test_result = self.worker.js_runtime.execute_script(
&located_script_name!(),
&format!(
r#"Deno[Deno.internal].runTests({})"#,
json!({ "shuffle": self.ps.options.shuffle_tests() }),
),
)?;
self.worker.js_runtime.resolve_value(test_result).await?;
self
.worker
.run_tests(&self.ps.options.shuffle_tests())
.await?;
loop {
if !self
.worker
@ -309,10 +298,7 @@ impl CliMainWorker {
&mut self,
mode: TestMode,
) -> Result<(), AnyError> {
self.worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].enableTestAndBench()"#,
)?;
self.worker.enable_test();
self
.worker
@ -328,14 +314,7 @@ impl CliMainWorker {
}
self.worker.dispatch_load_event(&located_script_name!())?;
let test_result = self.worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].runTests()"#,
)?;
self.worker.js_runtime.resolve_value(test_result).await?;
self.worker.run_tests(&None).await?;
loop {
if !self
.worker
@ -350,10 +329,7 @@ impl CliMainWorker {
}
pub async fn run_bench_specifier(&mut self) -> Result<(), AnyError> {
self.worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].enableTestAndBench()"#,
)?;
self.worker.enable_bench();
if self.ps.options.compat() {
self.worker.execute_side_module(&compat::GLOBAL_URL).await?;
@ -383,14 +359,7 @@ impl CliMainWorker {
}
self.worker.dispatch_load_event(&located_script_name!())?;
let bench_result = self.worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].runBenchmarks()"#,
)?;
self.worker.js_runtime.resolve_value(bench_result).await?;
self.worker.run_benchmarks().await?;
loop {
if !self
.worker