coverband 0.1.0.preRC3 → 0.1.0.preRC4

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: dc01b93ff5fb4a9ab86b129d9232b54a79cb55bb
4
- data.tar.gz: 18d556322f02b72cb975d1db2cb9a55d0eeb44ab
3
+ metadata.gz: c2b8156d50c00462d50ecf5e65c584a16a027357
4
+ data.tar.gz: 508cfa3982dbd3235af6ebf854799076d1e821ee
5
5
  SHA512:
6
- metadata.gz: 23443c8bebc98a504e9eea13fc26c5d5cf172c112875cfa0c3efa5472c5686c1c1f6aa2ed2f63948d0f258e9b4583e4dff7a9f1c895b122fd21e206a96291989
7
- data.tar.gz: 2631a30ee5e53acf30a0d80a2b85dbbc9a1cf099cda8ef65316c9ceb105d6c33df5132943852f08cae53c414a2b7a71335a21a67b57afe6a516db2c6f2d37c61
6
+ metadata.gz: cceef094ab5d86065ac8748174394fe5350f805e31314023040a0eae0c69bbd91355018bcaeda9739c45f5577346c8ca2a2123d5e5802537791bc0c3eefe099c
7
+ data.tar.gz: 061f6b81c43f3180665529e298c17fb893c57972dc4c319d5da9f932dd0cd14403dcf68077cfa74128ca4f99fbe6e721abf163040d4725503cf389a7ef9017ed
@@ -44,7 +44,7 @@ module Coverband
44
44
  @reporter = Coverband::RedisStore.new(Coverband.configuration.redis) if Coverband.configuration.redis
45
45
  @stats = Coverband.configuration.stats
46
46
  @verbose = Coverband.configuration.verbose
47
- @logger = Coverband.configuration.logger || Logger.new(STDOUT)
47
+ @logger = Coverband.configuration.logger
48
48
  self
49
49
  end
50
50
 
@@ -137,6 +137,16 @@ module Coverband
137
137
  end
138
138
 
139
139
  def add_file_without_checks(file, line)
140
+ # file from ruby coverband at this method call is a full path
141
+ # file from native coverband is also a full path
142
+ #
143
+ # at the moment the full paths don't merge so the 'last' one wins and each deploy
144
+ # with a normal capistrano setup resets coverage.
145
+ #
146
+ # should we make it relative in this method (slows down collection)
147
+ # -- OR --
148
+ # we could have the reporter MERGE the results after normalizing the filenames
149
+ # (went with this route see report_scov previous_line_hash)
140
150
  if @verbose
141
151
  @file_usage[file] += 1
142
152
  @file_line_usage[file] = Hash.new(0) unless @file_line_usage.include?(file)
@@ -12,7 +12,7 @@ module Coverband
12
12
  @percentage = 0.0
13
13
  @verbose = false
14
14
  @reporter = 'scov'
15
- @logger = nil
15
+ @logger = Logger.new(STDOUT)
16
16
  @startup_delay = 0
17
17
  end
18
18
  end
@@ -8,7 +8,10 @@ module Coverband
8
8
  @project_directory = File.expand_path(Coverband.configuration.root)
9
9
  results = Coverage.result
10
10
  results = results.reject{|key, val| !key.match(@project_directory) || Coverband.configuration.ignore.any?{|pattern| key.match(/#{pattern}/)} }
11
- puts results.inspect
11
+
12
+ if Coverband.configuration.verbose
13
+ Coverband.configuration.logger.info results.inspect
14
+ end
12
15
 
13
16
  File.open('./tmp/coverband_baseline.json', 'w') {|f| f.write(results.to_json) }
14
17
  end
@@ -17,7 +20,7 @@ module Coverband
17
20
  begin
18
21
  require 'simplecov' if Coverband.configuration.reporter=='scov'
19
22
  rescue
20
- puts "coverband requires simplecov in order to generate a report, when configured for the scov report style."
23
+ Coverband.configuration.logger.error "coverband requires simplecov in order to generate a report, when configured for the scov report style."
21
24
  return
22
25
  end
23
26
  redis = Coverband.configuration.redis
@@ -26,12 +29,16 @@ module Coverband
26
29
  open_report = options.fetch(:open_report){ true }
27
30
 
28
31
  roots << "#{current_root}/"
29
- puts "fixing root: #{roots.join(', ')}"
32
+
33
+ if Coverband.configuration.verbose
34
+ Coverband.configuration.logger.info "fixing root: #{roots.join(', ')}"
35
+ end
36
+
30
37
  if Coverband.configuration.reporter=='scov'
31
38
  report_scov(redis, existing_coverage, roots, open_report)
32
39
  else
33
40
  lines = redis.smembers('coverband').map{|key| report_line(redis, key) }
34
- puts lines.join("\n")
41
+ Coverband.configuration.logger.info lines.join("\n")
35
42
  end
36
43
  end
37
44
 
@@ -61,18 +68,30 @@ module Coverband
61
68
  redis.smembers('coverband').each do |key|
62
69
  next if Coverband.configuration.ignore.any?{ |i| key.match(i)}
63
70
  line_data = line_hash(redis, key, roots)
64
- scov_style_report.merge!(line_data) if line_data
71
+
72
+ if line_data
73
+ line_key = line_hash.keys.first
74
+ previous_line_hash = scov_style_report[line_key]
75
+ if merge_line
76
+ line_data[line_key] = line_data[line_key].merge(previous_line_hash)
77
+ end
78
+ scov_style_report.merge!(line_data)
79
+ end
65
80
  end
66
81
  scov_style_report = fix_file_names(scov_style_report, roots)
67
82
  existing_coverage = fix_file_names(existing_coverage, roots)
68
83
  scov_style_report = merge_existing_coverage(scov_style_report, existing_coverage)
69
- puts "report: "
70
- puts scov_style_report.inspect
84
+
85
+ if Coverband.configuration.verbose
86
+ Coverband.configuration.logger.info "report: "
87
+ Coverband.configuration.logger.info scov_style_report.inspect
88
+ end
89
+
71
90
  SimpleCov::Result.new(scov_style_report).format!
72
91
  if open_report
73
92
  `open #{SimpleCov.coverage_dir}/index.html`
74
93
  else
75
- puts "report is ready and viewable: open #{SimpleCov.coverage_dir}/index.html"
94
+ Coverband.configuration.logger.info "report is ready and viewable: open #{SimpleCov.coverage_dir}/index.html"
76
95
  end
77
96
  end
78
97
 
@@ -98,7 +117,7 @@ module Coverband
98
117
  # /Users/danmayer/projects/cover_band_server/app/rb: ["54", "55"]
99
118
  # /Users/danmayer/projects/cover_band_server/views/layout/erb: ["0", "33", "36", "37", "38", "39", "40", "62", "63", "66", "65532", "65533"]
100
119
  def self.report_line(redis, key)
101
- "#{key}: #{redis.smembers("coverband.#{key}").inspect}"
120
+ "#{key}: #{redis.smembers("coverband.#{key}").inspect}" #" fix line styles
102
121
  end
103
122
 
104
123
  def self.filename_from_key(key, roots)
@@ -106,6 +125,9 @@ module Coverband
106
125
  roots.each do |root|
107
126
  filename = filename.gsub(/^#{root}/, './')
108
127
  end
128
+ # the filename for SimpleCov is expected to be a full path.
129
+ # roots.last should be roots << current_root}/
130
+ # a fully expanded path of config.root
109
131
  filename = filename.gsub('./', roots.last)
110
132
  filename
111
133
  end
@@ -125,7 +147,7 @@ module Coverband
125
147
  line_array.each_with_index{|line,index| line_array[index]=1 if lines_hit.include?((index+1).to_s) }
126
148
  {filename => line_array}
127
149
  else
128
- puts "file #{filename} not found in project"
150
+ Coverband.configuration.logger.info "file #{filename} not found in project"
129
151
  end
130
152
  end
131
153
 
@@ -1,3 +1,3 @@
1
1
  module Coverband
2
- VERSION = "0.1.0.preRC3"
2
+ VERSION = "0.1.0.preRC4"
3
3
  end
@@ -22,7 +22,6 @@ class ReporterTest < Test::Unit::TestCase
22
22
 
23
23
  Coverband::Reporter.expects(:current_root).returns('/root_dir')
24
24
  fake_redis.expects(:smembers).with('coverband').returns(fake_coverband_members)
25
- Coverband::Reporter.expects('puts').with("fixing root: /app/, /root_dir/")
26
25
 
27
26
  fake_coverband_members.each do |key|
28
27
  fake_redis.expects(:smembers).with("coverband.#{key}").returns(["54", "55"])
@@ -33,11 +32,52 @@ class ReporterTest < Test::Unit::TestCase
33
32
  regexp_matches(/account/),
34
33
  regexp_matches(/54/)]
35
34
 
36
- Coverband::Reporter.expects('puts').with(all_of(*matchers))
35
+ Coverband.configuration.logger.expects('info').with(all_of(*matchers))
37
36
 
38
37
  Coverband::Reporter.report
39
38
  end
40
39
 
40
+
41
+ ####
42
+ # TODO
43
+ # attempting to write some tests around this reporter
44
+ # shows that it has become a disaster of self methods relying on side effects.
45
+ # Fix to standard class and methods.
46
+ ####
47
+ should "fix filename from a key with a swappable path" do
48
+ Coverband.configure do |config|
49
+ config.redis = fake_redis
50
+ config.reporter = 'std_out'
51
+ config.root = '/full/remote_app/path'
52
+ end
53
+
54
+ key = "/app/is/a/path.rb"
55
+ #the code takes config.root expands and adds a '/'
56
+ roots = ["/app/", '/full/remote_app/path/']
57
+
58
+ assert_equal "/full/remote_app/path/is/a/path.rb", Coverband::Reporter.filename_from_key(key, roots)
59
+ end
60
+
61
+ ####
62
+ # TODO
63
+ # attempting to write some tests around this reporter
64
+ # shows that it has become a disaster of self methods relying on side effects.
65
+ # Fix to standard class and methods.
66
+ ####
67
+ should "leave filename from a key with a local path" do
68
+ Coverband.configure do |config|
69
+ config.redis = fake_redis
70
+ config.reporter = 'std_out'
71
+ config.root = '/full/remote_app/path'
72
+ end
73
+
74
+ key = "/full/remote_app/path/is/a/path.rb"
75
+ #the code takes config.root expands and adds a '/'
76
+ roots = ["/app/", '/full/remote_app/path/']
77
+
78
+ assert_equal "/full/remote_app/path/is/a/path.rb", Coverband::Reporter.filename_from_key(key, roots)
79
+ end
80
+
41
81
  private
42
82
 
43
83
  def fake_redis
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.preRC3
4
+ version: 0.1.0.preRC4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler