1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

feat(coverage): add default coverage include dir (#21625)

This commit is contained in:
Yoshiya Hinosawa 2023-12-18 19:48:45 +09:00 committed by GitHub
parent 5b2caed7fd
commit 6b482d7392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,15 +84,16 @@ pub struct CompletionsFlags {
pub buf: Box<[u8]>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub enum CoverageType {
#[default]
Summary,
Detailed,
Lcov,
Html,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct CoverageFlags {
pub files: FileFlags,
pub output: Option<PathBuf>,
@ -1422,10 +1423,9 @@ Generate html reports from lcov:
)
.arg(
Arg::new("files")
.num_args(1..)
.num_args(0..)
.value_parser(value_parser!(PathBuf))
.action(ArgAction::Append)
.required(true)
.value_hint(ValueHint::AnyPath),
)
})
@ -3307,9 +3307,10 @@ fn completions_parse(
}
fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) {
let default_files = vec![PathBuf::from("coverage")];
let files = match matches.remove_many::<PathBuf>("files") {
Some(f) => f.collect(),
None => vec![],
None => default_files,
};
let ignore = match matches.remove_many::<PathBuf>("ignore") {
Some(f) => f.collect(),
@ -7914,10 +7915,9 @@ mod tests {
include: vec![PathBuf::from("foo.json")],
ignore: vec![],
},
output: None,
include: vec![r"^file:".to_string()],
exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()],
r#type: CoverageType::Summary
..CoverageFlags::default()
}),
..Flags::default()
}
@ -7950,6 +7950,27 @@ mod tests {
}
);
}
#[test]
fn coverage_with_default_files() {
let r = flags_from_vec(svec!["deno", "coverage",]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Coverage(CoverageFlags {
files: FileFlags {
include: vec![PathBuf::from("coverage")],
ignore: vec![],
},
include: vec![r"^file:".to_string()],
exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()],
..CoverageFlags::default()
}),
..Flags::default()
}
);
}
#[test]
fn location_with_bad_scheme() {
#[rustfmt::skip]