gcov2x 0.2.2
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 +7 -0
- data/.gitignore +37 -0
- data/.travis.yml +3 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +22 -0
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/bin/gcov2x +101 -0
- data/gcov2x.gemspec +15 -0
- data/lib/ansii_formatter.rb +34 -0
- data/lib/file.rb +84 -0
- data/lib/gcov2x.rb +4 -0
- data/lib/html_formatter.rb +68 -0
- data/lib/html_view.html.erb +186 -0
- data/lib/line.rb +37 -0
- data/lib/project.rb +65 -0
- data/lib/version.rb +3 -0
- data/lib/xml_formatter.rb +58 -0
- data/spec/data/data2/test3.cpp.gcov +22 -0
- data/spec/data/test.cpp.gcov +14 -0
- data/spec/data/test1.cpp.gcov +21 -0
- data/spec/data/test2.cpp.gcov +22 -0
- data/spec/file_spec.rb +73 -0
- data/spec/line_spec.rb +49 -0
- data/spec/project_spec.rb +84 -0
- data/spec/spec_helper.rb +8 -0
- data/src/Makefile +33 -0
- data/src/test.cpp +9 -0
- data/src/test.h +7 -0
- data/src/test1.cpp +16 -0
- data/src/test2.cpp +17 -0
- data/src/test3.cpp +17 -0
- data/tasks/rubygems.rake +3 -0
- data/tasks/spec.rake +8 -0
- metadata +79 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
-: 0:Source:test1.cpp
|
2
|
+
-: 0:Graph:test1.gcno
|
3
|
+
-: 0:Data:test1.gcda
|
4
|
+
-: 0:Runs:2
|
5
|
+
-: 0:Programs:1
|
6
|
+
-: 1:
|
7
|
+
-: 2:int reached( int i )
|
8
|
+
-: 3:{
|
9
|
+
2: 4: int j = i;
|
10
|
+
-: 5:
|
11
|
+
2: 6: if( j == 2 )
|
12
|
+
2: 7: return j;
|
13
|
+
-: 8:
|
14
|
+
#####: 9: return 3;
|
15
|
+
2: 10:}
|
16
|
+
-: 11:
|
17
|
+
-: 12:int unreached( int x )
|
18
|
+
-: 13:{
|
19
|
+
#####: 14: int y = x;
|
20
|
+
#####: 15: return y+3;
|
21
|
+
-: 16:}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
-: 0:Source:test2.cpp
|
2
|
+
-: 0:Graph:test2.gcno
|
3
|
+
-: 0:Data:test2.gcda
|
4
|
+
-: 0:Runs:3
|
5
|
+
-: 0:Programs:1
|
6
|
+
-: 1:
|
7
|
+
-: 2:int unreached2( int x )
|
8
|
+
-: 3:{
|
9
|
+
#####: 4: int y = x;
|
10
|
+
#####: 5: return y+3;
|
11
|
+
-: 6:}
|
12
|
+
-: 7:
|
13
|
+
-: 8:int reached2( int i )
|
14
|
+
-: 9:{
|
15
|
+
3: 10: int j = i;
|
16
|
+
-: 11:
|
17
|
+
3: 12: if( j == 2 )
|
18
|
+
3: 13: return j;
|
19
|
+
-: 14:
|
20
|
+
#####: 15: return 3;
|
21
|
+
3: 16:}
|
22
|
+
-: 17:
|
data/spec/file_spec.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
describe GCOV::File do
|
4
|
+
|
5
|
+
it "requires a filename" do
|
6
|
+
expect{ file = GCOV::File.new }.to raise_error
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#name" do
|
10
|
+
it "returns the filename it was given" do
|
11
|
+
file = GCOV::File.new "myfile.cpp"
|
12
|
+
expect(file.name).to eq("myfile.cpp")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#<<" do
|
17
|
+
it "doesn't allow adding lines outside of the add_lines block" do
|
18
|
+
file = GCOV::File.new "myfile.cpp"
|
19
|
+
expect{
|
20
|
+
file << GCOV::Line.new(1,4,"line 1")
|
21
|
+
}.to raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#add_lines" do
|
26
|
+
it "computes stats after adding lines" do
|
27
|
+
file = GCOV::File.new "myfile.cpp"
|
28
|
+
file.add_lines do
|
29
|
+
file << GCOV::Line.new(1,4,"line 1")
|
30
|
+
file << GCOV::Line.new(2,23,"line 2")
|
31
|
+
file << GCOV::Line.new(3,:none,"line 3")
|
32
|
+
file << GCOV::Line.new(4,:missed,"line 4")
|
33
|
+
file << GCOV::Line.new(5,:missed,"line 5")
|
34
|
+
end
|
35
|
+
expect(file.stats[:lines]).to eq(4)
|
36
|
+
expect(file.stats[:total_lines]).to eq(5)
|
37
|
+
expect(file.stats[:total_exec]).to eq(27)
|
38
|
+
expect(file.stats[:empty_lines]).to eq(1)
|
39
|
+
expect(file.stats[:exec_lines]).to eq(2)
|
40
|
+
expect(file.stats[:missed_lines]).to eq(2)
|
41
|
+
expect(file.stats[:coverage]).to eq(0.5)
|
42
|
+
expect(file.stats[:total_exec]).to eq(27)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#lines" do
|
47
|
+
it "returns no lines by default" do
|
48
|
+
file = GCOV::File.new "myfile.cpp"
|
49
|
+
expect(file.lines.count).to eq(0)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns the lines it was given" do
|
53
|
+
file = GCOV::File.new "myfile.cpp"
|
54
|
+
file.add_lines do
|
55
|
+
file << GCOV::Line.new(1,4,"line 1")
|
56
|
+
file << GCOV::Line.new(2,23,"line 2")
|
57
|
+
end
|
58
|
+
expect(file.lines.count).to eq(2)
|
59
|
+
expect(file.lines[0].number).to eq(1)
|
60
|
+
expect(file.lines[1].number).to eq(2)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".load" do
|
66
|
+
it "can load a gcov file" do
|
67
|
+
file = GCOV::File.load(File.join(File.dirname(__FILE__),"data/test.cpp.gcov"))
|
68
|
+
expect(file.lines.count).to eq(9)
|
69
|
+
expect(file.meta["Graph"]).to eq("test.gcno")
|
70
|
+
expect(file.meta["Runs"].to_i).to eq(1)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/line_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
describe GCOV::Line do
|
4
|
+
describe "#number" do
|
5
|
+
it "returns the number it was given" do
|
6
|
+
line = GCOV::Line.new 2, 4, "abcdef"
|
7
|
+
expect(line.number).to eq(2)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#count" do
|
12
|
+
it "returns the count it was given" do
|
13
|
+
line = GCOV::Line.new 2, 4, "abcdef"
|
14
|
+
expect(line.count).to eq(4)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#text" do
|
19
|
+
it "returns the text it was given" do
|
20
|
+
line = GCOV::Line.new 2, 4, "abcdef"
|
21
|
+
expect(line.text).to eq("abcdef")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".parse" do
|
26
|
+
it "parses gcov format line with count" do
|
27
|
+
line = GCOV::Line.parse " 2: 55: std::string StringUtil::ltrim( const std::string &s ) "
|
28
|
+
expect(line.number).to eq(55)
|
29
|
+
expect(line.count).to eq(2)
|
30
|
+
expect(line.text).to eq(" std::string StringUtil::ltrim( const std::string &s ) ")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "parses empty gcov format line" do
|
34
|
+
line = GCOV::Line.parse " -: 35: * don't worry about excessive copying."
|
35
|
+
expect(line.number).to eq(35)
|
36
|
+
expect(line.count).to eq(:none)
|
37
|
+
expect(line.text).to eq(" * don't worry about excessive copying.")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "parses missed gcov format line" do
|
41
|
+
line = GCOV::Line.parse " #####: 89: } "
|
42
|
+
expect(line.number).to eq(89)
|
43
|
+
expect(line.count).to eq(:missed)
|
44
|
+
expect(line.text).to eq(" } ")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
describe GCOV::Project do
|
4
|
+
|
5
|
+
describe "#name" do
|
6
|
+
it "can be given in the constructor" do
|
7
|
+
project = GCOV::Project.new "Test"
|
8
|
+
expect(project.name).to eq("Test")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is optional in the constructor" do
|
12
|
+
project = GCOV::Project.new
|
13
|
+
expect(project.name).to eq("")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be modified" do
|
17
|
+
project = GCOV::Project.new "Test"
|
18
|
+
project.name = "Test2"
|
19
|
+
expect(project.name).to eq("Test2")
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#files" do
|
25
|
+
it "returns no files if it is empty" do
|
26
|
+
project = GCOV::Project.new "Test"
|
27
|
+
expect(project.files.count).to eq(0)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns the files it has been given" do
|
31
|
+
project = GCOV::Project.new "Test"
|
32
|
+
project << GCOV::File.new("foobar.cpp")
|
33
|
+
project << GCOV::File.new("boofar.cpp")
|
34
|
+
expect(project.files.count).to eq(2)
|
35
|
+
expect(project.files[0].name).to eq("foobar.cpp")
|
36
|
+
expect(project.files[1].name).to eq("boofar.cpp")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".load_dir" do
|
41
|
+
it "loads all files in the given directory" do
|
42
|
+
project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data"))
|
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"))
|
46
|
+
end
|
47
|
+
|
48
|
+
it "recursively loads all files in the given directory structure" do
|
49
|
+
project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true)
|
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") )
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#add_file" do
|
58
|
+
it "adds the given file" do
|
59
|
+
project = GCOV::Project.new
|
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") )
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#add_dir" do
|
66
|
+
it "adds all files in the given directory" do
|
67
|
+
project = GCOV::Project.load_dir(File.join(File.dirname(__FILE__),"data","data2"))
|
68
|
+
project.add_dir(File.join(File.dirname(__FILE__),"data"))
|
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") )
|
72
|
+
end
|
73
|
+
|
74
|
+
it "recursively adds all files in the given directory" do
|
75
|
+
project = GCOV::Project.new
|
76
|
+
project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true)
|
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") )
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/src/Makefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
CXX=clang++
|
2
|
+
CFLAGS=-I. --coverage
|
3
|
+
DEPS = test.h
|
4
|
+
OBJ = test.o test1.o test2.o test3.o
|
5
|
+
OUTDIR = ../spec/data
|
6
|
+
|
7
|
+
all: $(OUTDIR)/test.cpp.gcov $(OUTDIR)/test1.cpp.gcov $(OUTDIR)/test2.cpp.gcov $(OUTDIR)/data2/test3.cpp.gcov
|
8
|
+
|
9
|
+
$(OUTDIR)/test.cpp.gcov: test.cpp.gcov
|
10
|
+
@cp -fv $< $@
|
11
|
+
|
12
|
+
$(OUTDIR)/test1.cpp.gcov: test1.cpp.gcov
|
13
|
+
@cp -fv $< $@
|
14
|
+
|
15
|
+
$(OUTDIR)/test2.cpp.gcov: test2.cpp.gcov
|
16
|
+
@cp -fv $< $@
|
17
|
+
|
18
|
+
$(OUTDIR)/data2/test3.cpp.gcov: test3.cpp.gcov
|
19
|
+
@cp -fv $< $@
|
20
|
+
|
21
|
+
%.cpp.gcov: %.cpp test
|
22
|
+
@./test
|
23
|
+
@llvm-cov -l -p $<
|
24
|
+
|
25
|
+
test: $(OBJ)
|
26
|
+
$(CXX) $(CFLAGS) -o $@ $^
|
27
|
+
|
28
|
+
%.o: %.cpp $(DEPS)
|
29
|
+
$(CXX) $(CFLAGS) -c -o $@ $<
|
30
|
+
|
31
|
+
clean:
|
32
|
+
@rm -f *.o *.gcda *.gcno *.gcov
|
33
|
+
@rm -f test
|
data/src/test.cpp
ADDED
data/src/test.h
ADDED
data/src/test1.cpp
ADDED
data/src/test2.cpp
ADDED
data/src/test3.cpp
ADDED
data/tasks/rubygems.rake
ADDED
data/tasks/spec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gcov2x
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mattias Bergbom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: gcov2x digests .gcov files generated by llvm-cov and translates them
|
14
|
+
into various common formats
|
15
|
+
email: mattias.bergbom@gmail.com
|
16
|
+
executables:
|
17
|
+
- gcov2x
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/gcov2x
|
29
|
+
- gcov2x.gemspec
|
30
|
+
- lib/ansii_formatter.rb
|
31
|
+
- lib/file.rb
|
32
|
+
- lib/gcov2x.rb
|
33
|
+
- lib/html_formatter.rb
|
34
|
+
- lib/html_view.html.erb
|
35
|
+
- lib/line.rb
|
36
|
+
- lib/project.rb
|
37
|
+
- lib/version.rb
|
38
|
+
- lib/xml_formatter.rb
|
39
|
+
- spec/data/data2/test3.cpp.gcov
|
40
|
+
- spec/data/test.cpp.gcov
|
41
|
+
- spec/data/test1.cpp.gcov
|
42
|
+
- spec/data/test2.cpp.gcov
|
43
|
+
- spec/file_spec.rb
|
44
|
+
- spec/line_spec.rb
|
45
|
+
- spec/project_spec.rb
|
46
|
+
- spec/spec_helper.rb
|
47
|
+
- src/Makefile
|
48
|
+
- src/test.cpp
|
49
|
+
- src/test.h
|
50
|
+
- src/test1.cpp
|
51
|
+
- src/test2.cpp
|
52
|
+
- src/test3.cpp
|
53
|
+
- tasks/rubygems.rake
|
54
|
+
- tasks/spec.rake
|
55
|
+
homepage: http://rubygems.org/gems/gcov2x
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: gcov parser and formatter
|
79
|
+
test_files: []
|