gcov2x 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffc25780e4cd8a34e6bdd34e5bc8e5e994b97bad
4
- data.tar.gz: cb9bf064b36beeea8d7c4049160ac6b1ac7446ac
3
+ metadata.gz: 58d688ca8f1b4d87a11eefe33917c15c194db646
4
+ data.tar.gz: 23ceb0bd68c3f8bd06fcf993d40e2d4c67e35f09
5
5
  SHA512:
6
- metadata.gz: 78ba1059c5cbdc8e892a7e1c83e65b3a6225fef14816d9f39a7607f4fc0af3f7426a94e8d6be0a9c0275bdaaa6f7fefdaadf67586a52e0d0a79705b0454cf77f
7
- data.tar.gz: 1d42409446b10421d95fad13fdef204680e7b960313f5c6ce57c40fee67c2943f3f2241d03f461e8a676aae9bb3431c8908c5a5c5d96bb5493363995e4924dc7
6
+ metadata.gz: c88533951e3585ab3ff227086576bcbdb5ec0c92f0a6e3635143bf206a4a63f6d251f765c52b99f261511c28f3ad1b87614025396b35cc12c82e0162b311893f
7
+ data.tar.gz: 98dd31b4a441f6b2c37a92ef71fa9c5b54da9aec7e8dbe0532491edf403e8333de8ab4b27c9dc556d6876226c73c8401a9f543c63ff183a3da4d3ba0091a8fb3
data/Gemfile CHANGED
@@ -1 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
1
3
  gemspec
data/lib/file.rb CHANGED
@@ -71,8 +71,7 @@ module GCOV
71
71
 
72
72
  end
73
73
 
74
- def <<(line)
75
- fail "need to be in add_lines block" unless @adding
74
+ def _add_line line
76
75
  if line.number == 0
77
76
  key,val = /([^:]+):(.*)$/.match(line.text).to_a[1..2]
78
77
  @meta[key] = val
@@ -81,16 +80,33 @@ module GCOV
81
80
  end
82
81
  end
83
82
 
83
+ def <<(line)
84
+ fail "need to be in add_lines block" unless @adding
85
+ _add_line line
86
+ end
87
+
84
88
  def self.load filename
85
- file = GCOV::File.new filename
89
+ files = []
90
+ file = nil
86
91
  ::File.open(filename, "r") do |file_handle|
87
- file.add_lines do
88
- file_handle.each_line do |line|
89
- file << GCOV::Line.parse(line)
90
- end
91
- end
92
- end
93
- file
92
+ file_handle.each_line do |line_|
93
+ line = GCOV::Line.parse(line_)
94
+ if line.number == 0
95
+ key,val = /([^:]+):(.*)$/.match(line.text).to_a[1..2]
96
+ if key == 'Source'
97
+ if !file.nil?
98
+ file._update_stats
99
+ files << file
100
+ end # if
101
+ file = GCOV::File.new val
102
+ end # if source
103
+ end # if line == 0
104
+ file._add_line line
105
+ end # each line
106
+ end# file_handle
107
+ file._update_stats
108
+ files << file
109
+ files
94
110
  end
95
111
 
96
112
  def self.demangle filename
data/lib/project.rb CHANGED
@@ -83,21 +83,25 @@ module GCOV
83
83
 
84
84
  filenames.select{ |filename|
85
85
  hash[:filter].nil? or hash[:filter].empty? or hash[:filter].select{|f| f.match(GCOV::File.demangle(filename) ) }.empty?
86
- }.map{|filename| GCOV::File.load filename }.each do |file|
87
- if hash[:filter].nil? or hash[:filter].empty? or hash[:filter].select{|f| f.match(::Pathname.new(file.meta['Source']).cleanpath.to_s) }.empty?
88
- self << file
89
- end
90
- end # files
86
+ }.map{|filename| GCOV::File.load filename }.each do |files|
87
+ files.each do |file|
88
+ if hash[:filter].nil? or hash[:filter].empty? or hash[:filter].select{|f| f.match(::Pathname.new(file.meta['Source']).cleanpath.to_s) }.empty?
89
+ self << file
90
+ end # if
91
+ end # each file
92
+ end # each file(s)
91
93
  end
92
94
  end
93
95
 
94
96
  def add_file path, hash={}
95
97
  add_files do
96
98
  if hash[:filter].nil? or !hash[:filter].match(GCOV::File.demangle(path))
97
- file = GCOV::File.load(path)
98
- if hash[:filter].nil? or !hash[:filter].match( ::Pathname.new(file.meta['Source']).cleanpath.to_s )
99
- self << file
100
- end # if
99
+ files = GCOV::File.load(path)
100
+ files.each do |file|
101
+ if hash[:filter].nil? or !hash[:filter].match( ::Pathname.new(file.meta['Source']).cleanpath.to_s )
102
+ self << file
103
+ end # if
104
+ end
101
105
  end # if
102
106
  end # add_files
103
107
  end # add_file
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GCOV
2
- VERSION = '0.4.4'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -0,0 +1,35 @@
1
+ -: 0:Source:test.cpp
2
+ -: 0:Graph:test.gcno
3
+ -: 0:Data:test.gcda
4
+ -: 0:Runs:1
5
+ -: 0:Programs:1
6
+ -: 1:#include "test.h"
7
+ -: 2:
8
+ -: 3:int main( int argc, const char* argv[] )
9
+ -: 4:{
10
+ 1: 5: reached(2);
11
+ 1: 6: reached2(2);
12
+ 1: 7: reached3(2);
13
+ 1: 8: return 0;
14
+ -: 9:}
15
+ -: 0:Source:test1.cpp
16
+ -: 0:Graph:test1.gcno
17
+ -: 0:Data:test1.gcda
18
+ -: 0:Runs:2
19
+ -: 0:Programs:1
20
+ -: 1:
21
+ -: 2:int reached( int i )
22
+ -: 3:{
23
+ 2: 4: int j = i;
24
+ -: 5:
25
+ 2: 6: if( j == 2 )
26
+ 2: 7: return j;
27
+ -: 8:
28
+ #####: 9: return 3;
29
+ 2: 10:}
30
+ -: 11:
31
+ -: 12:int unreached( int x )
32
+ -: 13:{
33
+ #####: 14: int y = x;
34
+ #####: 15: return y+3;
35
+ -: 16:}
@@ -77,11 +77,23 @@ describe GCOV::File do
77
77
 
78
78
  describe ".load" do
79
79
  it "can load a gcov file" do
80
- file = GCOV::File.load(File.join(File.dirname(__FILE__),"data/test.cpp.gcov"))
80
+ file = GCOV::File.load(File.join(File.dirname(__FILE__),"data/test.cpp.gcov"))[0]
81
81
  expect(file.lines.count).to eq(9)
82
82
  expect(file.meta["Graph"]).to eq("test.gcno")
83
83
  expect(file.meta["Runs"].to_i).to eq(1)
84
84
  end
85
+
86
+ it "should split concatenated gcov files into multiple objects" do
87
+ files = GCOV::File.load(File.join(File.dirname(__FILE__),"concat/test_cat.cpp.gcov"))
88
+
89
+ expect(files.count).to eq(2)
90
+ expect(files[0].meta["Source"]).to eq("test.cpp")
91
+ expect(files[1].meta["Source"]).to eq("test1.cpp")
92
+
93
+ expect(files[0].lines.count).to eq(9)
94
+ expect(files[0].meta["Graph"]).to eq("test.gcno")
95
+ expect(files[0].meta["Runs"].to_i).to eq(1)
96
+ end
85
97
  end
86
98
 
87
99
  describe ".demangle" do
@@ -41,15 +41,15 @@ describe GCOV::Project do
41
41
  it "loads all files in the given directory" do
42
42
  project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data"))
43
43
  expect(project.files.count).to eq(3)
44
- expect(project.files.map{|file|file.name}).to include(a_string_ending_with("test2.cpp.gcov"))
45
- expect(project.files.map{|file|file.name}).not_to include(a_string_ending_with("test3.cpp.gcov"))
44
+ expect(project.files.map{|file|file.name}).to include(a_string_ending_with("test2.cpp"))
45
+ expect(project.files.map{|file|file.name}).not_to include(a_string_ending_with("test3.cpp"))
46
46
  end
47
47
 
48
48
  it "recursively loads all files in the given directory structure" do
49
49
  project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true)
50
50
  expect(project.files.count).to eq(4)
51
- expect(project.files.map{|file|file.name}).to include(a_string_ending_with("test2.cpp.gcov"))
52
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp.gcov") )
51
+ expect(project.files.map{|file|file.name}).to include(a_string_ending_with("test2.cpp"))
52
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp") )
53
53
  end
54
54
 
55
55
  end
@@ -58,7 +58,7 @@ describe GCOV::Project do
58
58
  it "adds the given file" do
59
59
  project = GCOV::Project.new
60
60
  project.add_file(File.join(File.dirname(__FILE__),"data","test2.cpp.gcov"))
61
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp.gcov") )
61
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp") )
62
62
  end
63
63
  end
64
64
 
@@ -67,32 +67,32 @@ describe GCOV::Project do
67
67
  project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data","data2"))
68
68
  project.add_dir(File.join(File.dirname(__FILE__),"data"))
69
69
  expect(project.files.count).to eq(4)
70
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp.gcov") )
71
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp.gcov") )
70
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp") )
71
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp") )
72
72
  end
73
73
 
74
74
  it "recursively adds all files in the given directory" do
75
75
  project = GCOV::Project.new
76
76
  project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true)
77
77
  expect(project.files.count).to eq(4)
78
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp.gcov") )
79
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp.gcov") )
78
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp") )
79
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp") )
80
80
  end
81
81
 
82
82
  it "filters using given singular expression" do
83
83
  project = GCOV::Project.new
84
84
  project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true, :filter => /test2\.cpp/)
85
85
  expect(project.files.count).to eq(3)
86
- expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test2.cpp.gcov") )
87
- expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp.gcov") )
86
+ expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test2.cpp") )
87
+ expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp") )
88
88
  end
89
89
 
90
90
  it "filters using given array of expressions" do
91
91
  project = GCOV::Project.new
92
92
  project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true, :filter => [/test2\.cpp/,/test3\.cpp/])
93
93
  expect(project.files.count).to eq(2)
94
- expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test2.cpp.gcov") )
95
- expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test3.cpp.gcov") )
94
+ expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test2.cpp") )
95
+ expect(project.files.map{|file|file.name}).not_to include( a_string_ending_with("test3.cpp") )
96
96
  end
97
97
  end
98
98
 
data/src/Makefile CHANGED
@@ -2,22 +2,28 @@ CXX=clang++
2
2
  CFLAGS=-I. --coverage
3
3
  DEPS = test.h
4
4
  OBJ = test.o test1.o test2.o test3.o
5
- OUTDIR = ../spec/data
5
+ SPECDIR = ../spec/gcov2x
6
+ OUTDIR = $(SPECDIR)/data
7
+ OUTDIR_CAT = $(SPECDIR)/concat
6
8
 
7
- all: $(OUTDIR)/test.cpp.gcov $(OUTDIR)/test1.cpp.gcov $(OUTDIR)/test2.cpp.gcov $(OUTDIR)/data2/test3.cpp.gcov
9
+ all: $(OUTDIR)/test.cpp.gcov $(OUTDIR)/test1.cpp.gcov $(OUTDIR)/test2.cpp.gcov $(OUTDIR)/data2/test3.cpp.gcov $(OUTDIR)/data2/test3.cpp.gcov $(OUTDIR_CAT)/test_cat.cpp.gcov
8
10
 
9
- $(OUTDIR)/test.cpp.gcov: test.cpp.gcov
11
+ $(OUTDIR)/test.cpp.gcov: test.cpp.gcov $(OUTDIR)
10
12
  @cp -fv $< $@
11
13
 
12
- $(OUTDIR)/test1.cpp.gcov: test1.cpp.gcov
14
+ $(OUTDIR)/test1.cpp.gcov: test1.cpp.gcov $(OUTDIR)
13
15
  @cp -fv $< $@
14
16
 
15
- $(OUTDIR)/test2.cpp.gcov: test2.cpp.gcov
17
+ $(OUTDIR)/test2.cpp.gcov: test2.cpp.gcov $(OUTDIR)
16
18
  @cp -fv $< $@
17
19
 
18
- $(OUTDIR)/data2/test3.cpp.gcov: test3.cpp.gcov
20
+ $(OUTDIR)/data2/test3.cpp.gcov: test3.cpp.gcov $(OUTDIR)/data2
19
21
  @cp -fv $< $@
20
22
 
23
+ $(OUTDIR_CAT)/test_cat.cpp.gcov: test.cpp.gcov test1.cpp.gcov
24
+ @echo "\nCreating $@\n"
25
+ @cat $^ > $@
26
+
21
27
  %.cpp.gcov: %.cpp test
22
28
  @./test
23
29
  @llvm-cov -l -p $<
@@ -28,6 +34,15 @@ test: $(OBJ)
28
34
  %.o: %.cpp $(DEPS)
29
35
  $(CXX) $(CFLAGS) -c -o $@ $<
30
36
 
37
+ $(OUTDIR):
38
+ mkdir -p $(OUTDIR)
39
+
40
+ $(OUTDIR)/data2:
41
+ mkdir -p $(OUTDIR)/data2
42
+
43
+ $(OUTDIR_CAT):
44
+ mkdir -p $(OUTDIR_CAT)
45
+
31
46
  clean:
32
47
  @rm -f *.o *.gcda *.gcno *.gcov
33
48
  @rm -f test
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcov2x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattias Bergbom
@@ -148,6 +148,7 @@ files:
148
148
  - lib/project.rb
149
149
  - lib/version.rb
150
150
  - lib/xml_formatter.rb
151
+ - spec/gcov2x/concat/test_cat.cpp.gcov
151
152
  - spec/gcov2x/data/data2/test3.cpp.gcov
152
153
  - spec/gcov2x/data/test.cpp.gcov
153
154
  - spec/gcov2x/data/test1.cpp.gcov