From d68d1e202285df30893968c8ba71b4a0a769b357 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 8 Dec 2023 16:54:52 +0900 Subject: feat(coverage): add html reporter (#21495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartek IwaƄczuk --- cli/args/flags.rs | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'cli/args/flags.rs') diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 1acef2058..2eed2a183 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -84,13 +84,20 @@ pub struct CompletionsFlags { pub buf: Box<[u8]>, } +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum CoverageType { + Pretty, + Lcov, + Html, +} + #[derive(Clone, Debug, Eq, PartialEq)] pub struct CoverageFlags { pub files: FileFlags, pub output: Option, pub include: Vec, pub exclude: Vec, - pub lcov: bool, + pub r#type: CoverageType, } #[derive(Clone, Debug, Eq, PartialEq)] @@ -1397,6 +1404,14 @@ Generate html reports from lcov: .require_equals(true) .value_hint(ValueHint::FilePath), ) + .arg( + Arg::new("html") + .long("html") + .help( + "Output coverage report in HTML format in the given directory", + ) + .action(ArgAction::SetTrue), + ) .arg( Arg::new("files") .num_args(1..) @@ -3298,7 +3313,13 @@ fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) { Some(f) => f.collect(), None => vec![], }; - let lcov = matches.get_flag("lcov"); + let r#type = if matches.get_flag("lcov") { + CoverageType::Lcov + } else if matches.get_flag("html") { + CoverageType::Html + } else { + CoverageType::Pretty + }; let output = matches.remove_one::("output"); flags.subcommand = DenoSubcommand::Coverage(CoverageFlags { files: FileFlags { @@ -3308,7 +3329,7 @@ fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) { output, include, exclude, - lcov, + r#type, }); } @@ -7867,7 +7888,7 @@ mod tests { output: None, include: vec![r"^file:".to_string()], exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()], - lcov: false, + r#type: CoverageType::Pretty }), ..Flags::default() } @@ -7893,7 +7914,7 @@ mod tests { }, include: vec![r"^file:".to_string()], exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()], - lcov: true, + r#type: CoverageType::Lcov, output: Some(PathBuf::from("foo.lcov")), }), ..Flags::default() -- cgit v1.2.3