diff options
-rw-r--r-- | cli/flags.rs | 12 | ||||
-rw-r--r-- | cli/inspector.rs | 5 | ||||
-rw-r--r-- | cli/main.rs | 10 | ||||
-rw-r--r-- | cli/tests/test_coverage.out | 2 | ||||
-rw-r--r-- | cli/worker.rs | 2 |
5 files changed, 14 insertions, 17 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 63d4c15e0..af7bc2a08 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -71,7 +71,6 @@ pub enum DenoSubcommand { allow_none: bool, include: Option<Vec<String>>, filter: Option<String>, - coverage: bool, }, Types, Upgrade { @@ -107,6 +106,7 @@ pub struct Flags { pub ca_file: Option<String>, pub cached_only: bool, pub config_path: Option<String>, + pub coverage: bool, pub ignore: Vec<String>, pub import_map_path: Option<String>, pub inspect: Option<SocketAddr>, @@ -585,9 +585,8 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) { let filter = matches.value_of("filter").map(String::from); let coverage = matches.is_present("coverage"); - // Coverage implies `--inspect` if coverage { - flags.inspect = Some("127.0.0.1:9229".parse::<SocketAddr>().unwrap()); + flags.coverage = true; } let include = if matches.is_present("files") { @@ -607,7 +606,6 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) { include, filter, allow_none, - coverage, }; } @@ -2857,7 +2855,6 @@ mod tests { allow_none: true, quiet: false, include: Some(svec!["dir1/", "dir2/"]), - coverage: false, }, allow_net: true, ..Flags::default() @@ -2877,7 +2874,6 @@ mod tests { quiet: false, filter: Some("foo".to_string()), include: Some(svec!["dir1"]), - coverage: false, }, ..Flags::default() } @@ -2897,7 +2893,6 @@ mod tests { quiet: false, filter: Some("- foo".to_string()), include: Some(svec!["dir1"]), - coverage: false, }, ..Flags::default() } @@ -2922,9 +2917,8 @@ mod tests { quiet: false, filter: None, include: Some(svec!["dir1"]), - coverage: true, }, - inspect: Some("127.0.0.1:9229".parse::<SocketAddr>().unwrap()), + coverage: true, unstable: true, ..Flags::default() } diff --git a/cli/inspector.rs b/cli/inspector.rs index d0601c522..f68882e48 100644 --- a/cli/inspector.rs +++ b/cli/inspector.rs @@ -452,6 +452,11 @@ impl DenoInspector { &self, mut invoker_cx: Option<&mut Context>, ) -> Result<Poll<()>, BorrowMutError> { + // Short-circuit if there is no server + if self.server.is_none() { + return Ok(Poll::Ready(())); + } + // The futures this function uses do not have re-entrant poll() functions. // However it is can happpen that poll_sessions() gets re-entered, e.g. // when an interrupt request is honored while the inspector future is polled diff --git a/cli/main.rs b/cli/main.rs index 1518ca98e..f888a6c6c 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -543,7 +543,6 @@ async fn test_command( quiet: bool, allow_none: bool, filter: Option<String>, - coverage: bool, ) -> Result<(), AnyError> { let global_state = GlobalState::new(flags.clone())?; let cwd = std::env::current_dir().expect("No current directory"); @@ -587,7 +586,7 @@ async fn test_command( .file_fetcher .save_source_file_in_cache(&main_module, source_file); - let mut maybe_coverage_collector = if coverage { + let mut maybe_coverage_collector = if flags.coverage { let inspector = worker .inspector .as_mut() @@ -737,11 +736,8 @@ pub fn main() { include, allow_none, filter, - coverage, - } => test_command( - flags, include, fail_fast, quiet, allow_none, filter, coverage, - ) - .boxed_local(), + } => test_command(flags, include, fail_fast, quiet, allow_none, filter) + .boxed_local(), DenoSubcommand::Completions { buf } => { if let Err(e) = write_to_stdout_ignore_sigpipe(&buf) { eprintln!("{}", e); diff --git a/cli/tests/test_coverage.out b/cli/tests/test_coverage.out index f189a92ee..fc24d82d1 100644 --- a/cli/tests/test_coverage.out +++ b/cli/tests/test_coverage.out @@ -1,4 +1,4 @@ -[WILDCARD] +Check [WILDCARD]/$deno$test.ts running 1 tests test returnsHiSuccess ... ok ([WILDCARD]) diff --git a/cli/worker.rs b/cli/worker.rs index f6c518d0c..242a2f4b3 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -134,6 +134,8 @@ impl Worker { &mut isolate, Some(inspector_server.clone()), )) + } else if global_state.flags.coverage { + Some(DenoInspector::new(&mut isolate, None)) } else { None }; |