From 9efed4c7a3d32de62e9c9b5e0c6712ce97637abb Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 1 May 2023 14:35:23 -0400 Subject: refactor(cli): remove ProcState - add CliFactory (#18900) This removes `ProcState` and replaces it with a new `CliFactory` which initializes our "service structs" on demand. This isn't a performance improvement at the moment for `deno run`, but might unlock performance improvements in the future. --- cli/lsp/testing/execution.rs | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'cli/lsp/testing') diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 5dfb31013..4834cd0c9 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -6,11 +6,11 @@ use super::lsp_custom; use crate::args::flags_from_vec; use crate::args::DenoSubcommand; +use crate::factory::CliFactory; use crate::lsp::client::Client; use crate::lsp::client::TestingNotification; use crate::lsp::config; use crate::lsp::logging::lsp_log; -use crate::proc_state; use crate::tools::test; use crate::tools::test::FailFastTracker; use crate::tools::test::TestEventSender; @@ -218,16 +218,16 @@ impl TestRun { let args = self.get_args(); lsp_log!("Executing test run with arguments: {}", args.join(" ")); let flags = flags_from_vec(args.into_iter().map(String::from).collect())?; - let ps = proc_state::ProcState::from_flags(flags).await?; + let factory = CliFactory::from_flags(flags).await?; // Various test files should not share the same permissions in terms of // `PermissionsContainer` - otherwise granting/revoking permissions in one // file would have impact on other files, which is undesirable. let permissions = - Permissions::from_options(&ps.options.permissions_options())?; + Permissions::from_options(&factory.cli_options().permissions_options())?; test::check_specifiers( - &ps.options, - &ps.file_fetcher, - &ps.module_load_preparer, + factory.cli_options(), + factory.file_fetcher()?, + factory.module_load_preparer().await?, self .queue .iter() @@ -236,18 +236,19 @@ impl TestRun { ) .await?; - let (concurrent_jobs, fail_fast) = - if let DenoSubcommand::Test(test_flags) = ps.options.sub_command() { - ( - test_flags - .concurrent_jobs - .unwrap_or_else(|| NonZeroUsize::new(1).unwrap()) - .into(), - test_flags.fail_fast, - ) - } else { - unreachable!("Should always be Test subcommand."); - }; + let (concurrent_jobs, fail_fast) = if let DenoSubcommand::Test(test_flags) = + factory.cli_options().sub_command() + { + ( + test_flags + .concurrent_jobs + .unwrap_or_else(|| NonZeroUsize::new(1).unwrap()) + .into(), + test_flags.fail_fast, + ) + } else { + unreachable!("Should always be Test subcommand."); + }; let (sender, mut receiver) = mpsc::unbounded_channel::(); let sender = TestEventSender::new(sender); @@ -259,7 +260,8 @@ impl TestRun { let tests: Arc>> = Arc::new(RwLock::new(IndexMap::new())); let mut test_steps = IndexMap::new(); - let worker_factory = Arc::new(ps.create_cli_main_worker_factory()); + let worker_factory = + Arc::new(factory.create_cli_main_worker_factory().await?); let join_handles = queue.into_iter().map(move |specifier| { let specifier = specifier.clone(); -- cgit v1.2.3