mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(coverage): add default coverage include dir (#21625)
This commit is contained in:
parent
5b2caed7fd
commit
6b482d7392
1 changed files with 28 additions and 7 deletions
|
@ -84,15 +84,16 @@ pub struct CompletionsFlags {
|
||||||
pub buf: Box<[u8]>,
|
pub buf: Box<[u8]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq, Default)]
|
||||||
pub enum CoverageType {
|
pub enum CoverageType {
|
||||||
|
#[default]
|
||||||
Summary,
|
Summary,
|
||||||
Detailed,
|
Detailed,
|
||||||
Lcov,
|
Lcov,
|
||||||
Html,
|
Html,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq, Default)]
|
||||||
pub struct CoverageFlags {
|
pub struct CoverageFlags {
|
||||||
pub files: FileFlags,
|
pub files: FileFlags,
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
@ -1422,10 +1423,9 @@ Generate html reports from lcov:
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("files")
|
Arg::new("files")
|
||||||
.num_args(1..)
|
.num_args(0..)
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
.action(ArgAction::Append)
|
.action(ArgAction::Append)
|
||||||
.required(true)
|
|
||||||
.value_hint(ValueHint::AnyPath),
|
.value_hint(ValueHint::AnyPath),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -3307,9 +3307,10 @@ fn completions_parse(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
|
let default_files = vec![PathBuf::from("coverage")];
|
||||||
let files = match matches.remove_many::<PathBuf>("files") {
|
let files = match matches.remove_many::<PathBuf>("files") {
|
||||||
Some(f) => f.collect(),
|
Some(f) => f.collect(),
|
||||||
None => vec![],
|
None => default_files,
|
||||||
};
|
};
|
||||||
let ignore = match matches.remove_many::<PathBuf>("ignore") {
|
let ignore = match matches.remove_many::<PathBuf>("ignore") {
|
||||||
Some(f) => f.collect(),
|
Some(f) => f.collect(),
|
||||||
|
@ -7914,10 +7915,9 @@ mod tests {
|
||||||
include: vec![PathBuf::from("foo.json")],
|
include: vec![PathBuf::from("foo.json")],
|
||||||
ignore: vec![],
|
ignore: vec![],
|
||||||
},
|
},
|
||||||
output: None,
|
|
||||||
include: vec![r"^file:".to_string()],
|
include: vec![r"^file:".to_string()],
|
||||||
exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()],
|
exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()],
|
||||||
r#type: CoverageType::Summary
|
..CoverageFlags::default()
|
||||||
}),
|
}),
|
||||||
..Flags::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]
|
#[test]
|
||||||
fn location_with_bad_scheme() {
|
fn location_with_bad_scheme() {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue