ruby-changes:47147
From: mame <ko1@a...>
Date: Wed, 5 Jul 2017 01:02:29 +0900 (JST)
Subject: [ruby-changes:47147] mame:r59262 (trunk): Use lcov visualizer for gcov statistics
mame 2017-07-05 01:02:19 +0900 (Wed, 05 Jul 2017) New Revision: 59262 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59262 Log: Use lcov visualizer for gcov statistics This experimental feature is only for Ruby-core team, not for casual users. Usage: `./configure --enable-gcov && make && make exam && make lcov` Added files: trunk/tool/run-lcov.rb Modified files: trunk/.gitignore trunk/Makefile.in Index: .gitignore =================================================================== --- .gitignore (revision 59261) +++ .gitignore (revision 59262) @@ -39,6 +39,7 @@ y.tab.c https://github.com/ruby/ruby/blob/trunk/.gitignore#L39 *.gcda *.gcno *.gcov +lcov*.info # / /*-fake.rb @@ -85,6 +86,7 @@ y.tab.c https://github.com/ruby/ruby/blob/trunk/.gitignore#L86 /goruby /id.[ch] /largefile.h +/lcov-out /lex.c /libruby*.* /miniprelude.c Index: tool/run-lcov.rb =================================================================== --- tool/run-lcov.rb (nonexistent) +++ tool/run-lcov.rb (revision 59262) @@ -0,0 +1,41 @@ https://github.com/ruby/ruby/blob/trunk/tool/run-lcov.rb#L1 +#!ruby +require "pathname" +require "open3" + +def backup_gcda_files(gcda_files) + gcda_files = gcda_files.map do |gcda| + [gcda, gcda.sub_ext(".bak")] + end + begin + gcda_files.each do |before, after| + before.rename(after) + end + yield + ensure + gcda_files.each do |before, after| + after.rename(before) + end + end +end + +$info_files = [] +def run_lcov(dir, info) + $info_files << info + system("lcov", "-c", "-d", dir, "--rc", "lcov_branch_coverage=1", "-o", info) +end + +gcda_files = Pathname.glob("**/*.gcda") +ext_gcda_files = gcda_files.select {|f| f.fnmatch("ext/*") } +rubyspec_temp_gcda_files = gcda_files.select {|f| f.fnmatch("rubyspec_temp/*") } + +backup_gcda_files(rubyspec_temp_gcda_files) do + backup_gcda_files(ext_gcda_files) do + info = "lcov-root.info" + run_lcov(".", info) + end + ext_gcda_files.group_by {|f| f.descend.to_a[1] }.each do |key, files| + info = "lcov-#{ key.to_s.gsub(File::Separator, "-") }.info" + run_lcov(key.to_s, info) + end +end +system("lcov", *$info_files.flat_map {|f| ["-a", f] }, "-o", "lcov-c-all.info") Index: Makefile.in =================================================================== --- Makefile.in (revision 59261) +++ Makefile.in (revision 59262) @@ -484,6 +484,10 @@ after-update:: prereq https://github.com/ruby/ruby/blob/trunk/Makefile.in#L484 gcov: $(Q) $(BASERUBY) $(srcdir)/tool/run-gcov.rb +lcov: + $(Q) $(BASERUBY) $(srcdir)/tool/run-lcov.rb + $(Q) genhtml --ignore-errors source lcov-c-all.info -o lcov-out + update-doclie: $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \ --branch $(DOCLIE_GIT_REF) \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/