Skip to content

Commit ac9e84d

Browse files
committed
Support LCOV 2.0
LCOV 2.0, a GCOV frontend, seems to have stricter error checking
1 parent 47364c1 commit ac9e84d

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3823,7 +3823,7 @@ AC_ARG_ENABLE(gcov,
38233823
AS_HELP_STRING([--enable-gcov], [enable coverage measurement by gcov]),
38243824
[gcov=yes])
38253825
AS_IF([test x"$gcov" = xyes], [
3826-
CFLAGS="$CFLAGS -coverage"
3826+
CFLAGS="$CFLAGS -coverage -fprofile-update=atomic"
38273827
LDFLAGS="$LDFLAGS -coverage"
38283828
])
38293829

tool/run-gcov.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
)?
4848
Creating\ .*\n
4949
\n
50-
)+\z
50+
)+
51+
(Lines\ executed:.*\n)?\z
5152
)x
5253
raise "Unexpected gcov output"
5354
end

tool/run-lcov.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def backup_gcda_files(gcda_files)
2020
end
2121

2222
def run_lcov(*args)
23-
system("lcov", "--rc", "lcov_branch_coverage=1", *args)
23+
system("lcov", "--rc", "geninfo_unexecuted_blocks=1", "--rc", "lcov_branch_coverage=1", *args, exception: true)
2424
end
2525

2626
$info_files = []
@@ -41,11 +41,19 @@ def run_lcov_remove(info_src, info_out)
4141
ext/-test-/*
4242
ext/nkf/nkf-utf8/nkf.c
4343
).each {|f| dirs << File.join(File.dirname(__dir__), f) }
44-
run_lcov("--remove", info_src, *dirs, "-o", info_out)
44+
run_lcov("--ignore-errors", "unused", "--remove", info_src, *dirs, "-o", info_out)
4545
end
4646

4747
def run_genhtml(info, out)
48-
system("genhtml", "--branch-coverage", "--ignore-errors", "source", info, "-o", out)
48+
base_dir = File.dirname(File.dirname(__dir__))
49+
ignore_errors = %w(source unmapped category).reject do |a|
50+
Open3.capture3("genhtml", "--ignore-errors", a)[1].include?("unknown argument for --ignore-errors")
51+
end
52+
system("genhtml",
53+
"--branch-coverage",
54+
"--prefix", base_dir,
55+
*ignore_errors.flat_map {|a| ["--ignore-errors", a] },
56+
info, "-o", out, exception: true)
4957
end
5058

5159
def gen_rb_lcov(file)

0 commit comments

Comments
 (0)