Support LCOV 2.0

LCOV 2.0, a GCOV frontend, seems to have stricter error checking
This commit is contained in:
Yusuke Endoh 2024-06-21 12:38:18 +09:00
parent 47364c147d
commit ac9e84df3d
3 changed files with 14 additions and 5 deletions

View File

@ -3823,7 +3823,7 @@ AC_ARG_ENABLE(gcov,
AS_HELP_STRING([--enable-gcov], [enable coverage measurement by gcov]),
[gcov=yes])
AS_IF([test x"$gcov" = xyes], [
CFLAGS="$CFLAGS -coverage"
CFLAGS="$CFLAGS -coverage -fprofile-update=atomic"
LDFLAGS="$LDFLAGS -coverage"
])

View File

@ -47,7 +47,8 @@ Pathname.glob("**/*.gcda").sort.each do |gcda|
)?
Creating\ .*\n
\n
)+\z
)+
(Lines\ executed:.*\n)?\z
)x
raise "Unexpected gcov output"
end

View File

@ -20,7 +20,7 @@ def backup_gcda_files(gcda_files)
end
def run_lcov(*args)
system("lcov", "--rc", "lcov_branch_coverage=1", *args)
system("lcov", "--rc", "geninfo_unexecuted_blocks=1", "--rc", "lcov_branch_coverage=1", *args, exception: true)
end
$info_files = []
@ -41,11 +41,19 @@ def run_lcov_remove(info_src, info_out)
ext/-test-/*
ext/nkf/nkf-utf8/nkf.c
).each {|f| dirs << File.join(File.dirname(__dir__), f) }
run_lcov("--remove", info_src, *dirs, "-o", info_out)
run_lcov("--ignore-errors", "unused", "--remove", info_src, *dirs, "-o", info_out)
end
def run_genhtml(info, out)
system("genhtml", "--branch-coverage", "--ignore-errors", "source", info, "-o", out)
base_dir = File.dirname(File.dirname(__dir__))
ignore_errors = %w(source unmapped category).reject do |a|
Open3.capture3("genhtml", "--ignore-errors", a)[1].include?("unknown argument for --ignore-errors")
end
system("genhtml",
"--branch-coverage",
"--prefix", base_dir,
*ignore_errors.flat_map {|a| ["--ignore-errors", a] },
info, "-o", out, exception: true)
end
def gen_rb_lcov(file)