1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 03:44:05 -05:00

fix(cli/test): do not start inspector server when collecting coverage (#7718)

This commit is contained in:
Casper Beyer 2020-09-28 18:22:29 +08:00 committed by GitHub
parent 45d4fd44c9
commit 6587d1bce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 17 deletions

View file

@ -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()
}

View file

@ -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

View file

@ -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,10 +736,7 @@ pub fn main() {
include,
allow_none,
filter,
coverage,
} => test_command(
flags, include, fail_fast, quiet, allow_none, filter, coverage,
)
} => 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) {

View file

@ -1,4 +1,4 @@
[WILDCARD]
Check [WILDCARD]/$deno$test.ts
running 1 tests
test returnsHiSuccess ... ok ([WILDCARD])

View file

@ -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
};