gcov2x 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdc831448c19f5be4b75fe23d72e969ae0390ca6
4
- data.tar.gz: 735ec1f4a87e97880837faf992899bda1f712f12
3
+ metadata.gz: 250132fce3ed7347f085dbe31b8f51eacb2a91d8
4
+ data.tar.gz: 73615a81b7a41d1a4b0ab09ac73f8153ef5ddb54
5
5
  SHA512:
6
- metadata.gz: 1ea12bc955a2d3984d95934fb02e2b7f96b746aac5d8ba7335b474099cd4c7b5c786459a2ed2f6c9b41f78b430e53e827eeeb9d5f12243a954a21ad552f23d11
7
- data.tar.gz: e7ccfe147559bd8a5eae232394bf5ecf472e89aced0707cedd13d3fcb1f362d04b96b3d0260c76c5bf772ff0dce0438125e86d64534d11a39ab238692bce67d5
6
+ metadata.gz: 2168fcd1772a4a6cd9d58132480d231a9101214d6eb966008da33fdfaf69bb8e051b8d61416445929e4cfdfb311f41089f77f8bab41cd7a90496198e66460858
7
+ data.tar.gz: 58677468ee5076e3ccfa2b339db16c27c9ec7241918964481c3dd1de78dbd5f8a192f552cff654f8fc63399fdd8e16e90ddab8afabed86655ab87b920bf73a6c
data/bin/gcov2x CHANGED
@@ -19,11 +19,17 @@ class CGOV_CLI
19
19
 
20
20
  option :filter,
21
21
  :long => "--filter FILTER",
22
- :description => Util.opt_wrap("A regex filter which specifies which files not to include in the conversion. Will filter on the actual filename (replacing any mangling done by llvm-cov using #'s) as well as the 'Source' meta attribute in the GCOV data. Available presets:
23
- xcode - Xcode system headers
24
- linux - Linux system headers
22
+ :description => Util.opt_wrap("A semicolon-separated list of regex filters which specify which files NOT to include in the conversion. Will filter on the actual filename (replacing any mangling done by llvm-cov using #'s) as well as the 'Source' meta attribute in the GCOV data.
23
+ Available presets:
24
+ :xcode - Xcode system headers
25
+ :linux - Linux system headers
25
26
  "),
26
- :proc => Proc.new { |f| (f.size > 0 and f[0] == ":" ? f[1..-1].to_sym : f ) }
27
+ :proc => Proc.new { |f|
28
+ values = f.split(';')
29
+ values = values.map{|f| f.size > 0 and f[0] == ":" ? f[1..-1].to_sym : f }
30
+ values
31
+ },
32
+ :on => :tail
27
33
 
28
34
  option :format,
29
35
  :short => "-f FORMAT",
@@ -66,13 +72,16 @@ fail "Got no filename" unless filenames.is_a? Array and filenames.count > 0
66
72
 
67
73
  proj = GCOV::Project.new
68
74
 
69
- filter = case cli.config[:filter]
70
- when :xcode then /Developer\/(Toolchains|Platforms)\/.*\/usr\/include\//
71
- when :linux then /\/usr\/include\//
72
- when nil then nil
73
- else /#{cli.config[:filter]}/
74
- end
75
-
75
+ filter = []
76
+ cli.config[:filter].each do |f|
77
+ filter << case f
78
+ when :xcode then /Developer\/(Toolchains|Platforms)\/.*\/usr\/include\//
79
+ when :linux then /\/usr\/include\//
80
+ when nil then nil
81
+ else /#{f}/
82
+ end
83
+ end # f
84
+
76
85
  filenames.each do |filename|
77
86
  if File.directory? filename
78
87
  proj.add_dir filename, :recursive => cli.config[:recursive], :filter => filter
data/lib/project.rb CHANGED
@@ -67,9 +67,16 @@ module GCOV
67
67
  else
68
68
  filenames = Dir["#{path}/*.gcov"]
69
69
  end
70
+
71
+ # legacy support
72
+ if !hash[:filter].nil? and ( hash[:filter].is_a? Regexp )
73
+ hash[:filter] = [ hash[:filter] ]
74
+ end
70
75
 
71
- filenames.select{|filename| ( hash[:filter].nil? or !hash[:filter].match(GCOV::File.demangle(filename))) }.map{|filename| GCOV::File.load filename }.each do |file|
72
- if hash[:filter].nil? or !hash[:filter].match( ::File.realpath(file.meta['Source']) )
76
+ filenames.select{ |filename|
77
+ hash[:filter].nil? or hash[:filter].empty? or hash[:filter].select{|f| f.match(GCOV::File.demangle(filename) ) }.empty?
78
+ }.map{|filename| GCOV::File.load filename }.each do |file|
79
+ if hash[:filter].nil? or hash[:filter].empty? or hash[:filter].select{|f| f.match(::Pathname.new(file.meta['Source']).cleanpath.to_s) }.empty?
73
80
  self << file
74
81
  end
75
82
  end # files
@@ -80,7 +87,7 @@ module GCOV
80
87
  add_files do
81
88
  if hash[:filter].nil? or !hash[:filter].match(GCOV::File.demangle(path))
82
89
  file = GCOV::File.load(path)
83
- if hash[:filter].nil? or !hash[:filter].match( ::File.realpath(file.meta['Source']) )
90
+ if hash[:filter].nil? or !hash[:filter].match( ::Pathname.new(file.meta['Source']).cleanpath.to_s )
84
91
  self << file
85
92
  end # if
86
93
  end # if
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GCOV
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -78,6 +78,22 @@ describe GCOV::Project do
78
78
  expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test2.cpp.gcov") )
79
79
  expect(project.files.map{|file|file.name}).to include( a_string_ending_with("test3.cpp.gcov") )
80
80
  end
81
+
82
+ it "filters using given singular expression" do
83
+ project = GCOV::Project.new
84
+ project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true, :filter => /test2\.cpp/)
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") )
88
+ end
89
+
90
+ it "filters using given array of expressions" do
91
+ project = GCOV::Project.new
92
+ project.add_dir(File.join(File.dirname(__FILE__),"data"), :recursive => true, :filter => [/test2\.cpp/,/test3\.cpp/])
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") )
96
+ end
81
97
  end
82
98
 
83
99
 
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattias Bergbom