[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / tool / run-gcov.rb
blob5df7622aa371d430f74a65088fc3203d6878ed1d
1 #!ruby
2 require "pathname"
3 require "open3"
5 Pathname.glob("**/*.gcda").sort.each do |gcda|
6   if gcda.fnmatch("ext/*")
7     cwd, gcda = gcda.split.map {|s| s.to_s }
8     objdir = "."
9   elsif gcda.fnmatch("rubyspec_temp/*")
10     next
11   else
12     cwd, objdir, gcda = ".", gcda.dirname.to_s, gcda.to_s
13   end
14   puts "$ gcov -lpbc -o #{ objdir } #{ gcda }"
15   out, err, _status = Open3.capture3("gcov", "-lpbc", "-o", objdir, gcda, chdir: cwd)
16   puts out
17   puts err
19   # a black list of source files that contains wrong #line directives
20   if err !~ %r(
21     \A(
22       Cannot\ open\ source\ file\ (
23          defs/keywords
24         |zonetab\.list
25         |enc/jis/props\.kwd
26         |parser\.c
27         |parser\.rl
28       )\n
29     )*\z
30   )x
31     raise "Unexpected gcov output"
32   end
34   if out !~ %r(
35     \A(
36       File\ .*\nLines\ executed:.*\n
37       (
38         Branches\ executed:.*\n
39         Taken\ at\ least\ once:.*\n
40       |
41         No\ branches\n
42       )?
43       (
44         Calls\ executed:.*\n
45       |
46         No\ calls\n
47       )?
48       Creating\ .*\n
49       \n
50     )+\z
51   )x
52     raise "Unexpected gcov output"
53   end
54 end