Skip to content

Commit aa12174

Browse files
Euccas Chenoberpar
authored andcommitted
genhtml: Implement option to specify coverage rate precision
Add command line support and config file support for specifying the coverage rate precision, valid precision range: [1,4]. Signed-off-by: Euccas Chen <[email protected]>
1 parent 4d4eba1 commit aa12174

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bin/genhtml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ our $lcov_version = 'LCOV version '.`$tool_dir/get_version.sh --version`;
7979
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
8080
our $tool_name = basename($0);
8181

82+
# Specify coverage rate default precision
83+
our $default_precision = 1;
84+
8285
# Specify coverage rate limits (in %) for classifying file entries
8386
# HI: $hi_limit <= rate <= 100 graph color: green
8487
# MED: $med_limit <= rate < $hi_limit graph color: orange
@@ -355,6 +358,7 @@ if ($config || %opt_rc)
355358
"genhtml_html_epilog" => \$html_epilog_file,
356359
"genhtml_html_extension" => \$html_ext,
357360
"genhtml_html_gzip" => \$html_gzip,
361+
"genhtml_precision" => \$default_precision,
358362
"genhtml_function_hi_limit" => \$fn_hi_limit,
359363
"genhtml_function_med_limit" => \$fn_med_limit,
360364
"genhtml_function_coverage" => \$func_coverage,
@@ -410,6 +414,7 @@ if (!GetOptions("output-directory|o=s" => \$output_directory,
410414
"ignore-errors=s" => \@opt_ignore_errors,
411415
"config-file=s" => \$opt_config_file,
412416
"rc=s%" => \%opt_rc,
417+
"precision=i" => \$default_precision,
413418
))
414419
{
415420
print(STDERR "Use $tool_name --help to get usage information\n");
@@ -533,6 +538,13 @@ if ($demangle_cpp)
533538
}
534539
}
535540

541+
# Make sure precision is within valid range
542+
if ($default_precision < 1 || $default_precision > 4)
543+
{
544+
die("ERROR: specified precision is out of range (1 to 4)\n");
545+
}
546+
547+
536548
# Make sure output_directory exists, create it if necessary
537549
if ($output_directory)
538550
{
@@ -600,6 +612,7 @@ HTML output:
600612
--html-gzip Use gzip to compress HTML
601613
--(no-)sort Enable (disable) sorted coverage views
602614
--demangle-cpp Demangle C++ function names
615+
--precision NUM Set precision of coverage rate
603616
604617
For more information see: $lcov_url
605618
END_OF_USAGE
@@ -5963,7 +5976,7 @@ sub rate($$;$$$)
59635976
my $rate;
59645977

59655978
# Assign defaults if necessary
5966-
$precision = 1 if (!defined($precision));
5979+
$precision = $default_precision if (!defined($precision));
59675980
$suffix = "" if (!defined($suffix));
59685981
$width = 0 if (!defined($width));
59695982

0 commit comments

Comments
 (0)