diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-09-11 00:20:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 00:20:03 +0100 |
commit | f959297dcd382b25bdedd0ff6aa27e8fb40e7ecd (patch) | |
tree | f30f58be88150fb49b6207aee79058714197f3aa /cli/lsp/testing | |
parent | 4865ae13e1a637a86de1266f1f5147b6142872c6 (diff) |
feat(lsp): unstable setting as list (#25552)
Diffstat (limited to 'cli/lsp/testing')
-rw-r--r-- | cli/lsp/testing/execution.rs | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 4ac565aa0..a952f2c49 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -33,6 +33,7 @@ use deno_runtime::deno_permissions::Permissions; use deno_runtime::tokio_util::create_and_run_current_thread; use indexmap::IndexMap; use lsp_types::Uri; +use std::borrow::Cow; use std::collections::HashMap; use std::collections::HashSet; use std::num::NonZeroUsize; @@ -219,8 +220,9 @@ impl TestRun { ) -> Result<(), AnyError> { let args = self.get_args(); lsp_log!("Executing test run with arguments: {}", args.join(" ")); - let flags = - Arc::new(flags_from_vec(args.into_iter().map(From::from).collect())?); + let flags = Arc::new(flags_from_vec( + args.into_iter().map(|s| From::from(s.as_ref())).collect(), + )?); let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; // Various test files should not share the same permissions in terms of @@ -452,37 +454,42 @@ impl TestRun { Ok(()) } - fn get_args(&self) -> Vec<&str> { - let mut args = vec!["deno", "test"]; + fn get_args(&self) -> Vec<Cow<str>> { + let mut args = vec![Cow::Borrowed("deno"), Cow::Borrowed("test")]; args.extend( self .workspace_settings .testing .args .iter() - .map(|s| s.as_str()), + .map(|s| Cow::Borrowed(s.as_str())), ); - args.push("--trace-leaks"); - if self.workspace_settings.unstable && !args.contains(&"--unstable") { - args.push("--unstable"); + args.push(Cow::Borrowed("--trace-leaks")); + for unstable_feature in self.workspace_settings.unstable.as_deref() { + let flag = format!("--unstable-{unstable_feature}"); + if !args.contains(&Cow::Borrowed(&flag)) { + args.push(Cow::Owned(flag)); + } } if let Some(config) = &self.workspace_settings.config { - if !args.contains(&"--config") && !args.contains(&"-c") { - args.push("--config"); - args.push(config.as_str()); + if !args.contains(&Cow::Borrowed("--config")) + && !args.contains(&Cow::Borrowed("-c")) + { + args.push(Cow::Borrowed("--config")); + args.push(Cow::Borrowed(config.as_str())); } } if let Some(import_map) = &self.workspace_settings.import_map { - if !args.contains(&"--import-map") { - args.push("--import-map"); - args.push(import_map.as_str()); + if !args.contains(&Cow::Borrowed("--import-map")) { + args.push(Cow::Borrowed("--import-map")); + args.push(Cow::Borrowed(import_map.as_str())); } } if self.kind == lsp_custom::TestRunKind::Debug - && !args.contains(&"--inspect") - && !args.contains(&"--inspect-brk") + && !args.contains(&Cow::Borrowed("--inspect")) + && !args.contains(&Cow::Borrowed("--inspect-brk")) { - args.push("--inspect"); + args.push(Cow::Borrowed("--inspect")); } args } |