Skip to content

Commit

Permalink
refactor(cli): consolidate most MainWorker related code to the same p…
Browse files Browse the repository at this point in the history
…lace (denoland#15459)
  • Loading branch information
dsherret committed Aug 11, 2022
1 parent e4a5f99 commit c3b0468
Show file tree
Hide file tree
Showing 6 changed files with 621 additions and 539 deletions.
14 changes: 14 additions & 0 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ impl CliOptions {
&self.flags.subcommand
}

pub fn trace_ops(&self) -> bool {
match self.sub_command() {
DenoSubcommand::Test(flags) => flags.trace_ops,
_ => false,
}
}

pub fn shuffle_tests(&self) -> Option<u64> {
match self.sub_command() {
DenoSubcommand::Test(flags) => flags.shuffle,
_ => None,
}
}

pub fn type_check_mode(&self) -> TypeCheckMode {
self.flags.type_check_mode
}
Expand Down
35 changes: 1 addition & 34 deletions cli/lsp/testing/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::args::flags_from_vec;
use crate::args::DenoSubcommand;
use crate::checksum;
use crate::create_main_worker;
use crate::located_script_name;
use crate::lsp::client::Client;
use crate::lsp::client::TestingNotification;
use crate::lsp::config;
Expand Down Expand Up @@ -166,39 +165,7 @@ async fn test_specifier(
stderr: StdioPipe::File(sender.stderr()),
},
);

worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].enableTestAndBench()"#,
)?;

worker
.execute_script(
&located_script_name!(),
"Deno.core.enableOpCallTracing();",
)
.unwrap();

if mode != test::TestMode::Documentation {
worker.execute_side_module(&specifier).await?;
}

worker.dispatch_load_event(&located_script_name!())?;

let test_result = worker.js_runtime.execute_script(
&located_script_name!(),
r#"Deno[Deno.internal].runTests()"#,
)?;

worker.js_runtime.resolve_value(test_result).await?;

loop {
if !worker.dispatch_beforeunload_event(&located_script_name!())? {
break;
}
worker.run_event_loop(false).await?;
}
worker.dispatch_unload_event(&located_script_name!())?;
worker.run_lsp_test_specifier(mode).await?;
}

Ok(())
Expand Down
Loading

0 comments on commit c3b0468

Please sign in to comment.