From ac9e84df3d0b06e62498aafbca99e8f8475ec142 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 21 Jun 2024 12:38:18 +0900 Subject: [PATCH] Support LCOV 2.0 LCOV 2.0, a GCOV frontend, seems to have stricter error checking --- configure.ac | 2 +- tool/run-gcov.rb | 3 ++- tool/run-lcov.rb | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 0a55377bd9..fc52679a8b 100644 --- a/configure.ac +++ b/configure.ac @@ -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" ]) diff --git a/tool/run-gcov.rb b/tool/run-gcov.rb index 5df7622aa3..46626e4703 100644 --- a/tool/run-gcov.rb +++ b/tool/run-gcov.rb @@ -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 diff --git a/tool/run-lcov.rb b/tool/run-lcov.rb index f27578200a..bdccc29a11 100644 --- a/tool/run-lcov.rb +++ b/tool/run-lcov.rb @@ -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)