Skip TestProc#test_hash_does_not_change_after_compaction if compaction is not supported
[ruby.git] / tool / run-gcov.rb
blob46626e4703f4b405420d357d8063809c09877e77
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     )+
51     (Lines\ executed:.*\n)?\z
52   )x
53     raise "Unexpected gcov output"
54   end
55 end