coverband 2.0.2.alpha → 2.0.2.alpha2
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 +4 -4
- data/README.md +3 -3
- data/lib/coverband/adapters/memory_cache_store.rb +16 -16
- data/lib/coverband/configuration.rb +1 -1
- data/lib/coverband/reporters/web.rb +9 -0
- data/lib/coverband/version.rb +1 -1
- data/test/unit/adapters_memory_cache_store_test.rb +40 -30
- data/test/unit/reports_web_test.rb +22 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02246eb05ef94f9b83510eba25d096e582f2d2ed
|
4
|
+
data.tar.gz: a8af15031477e50a6e395b54b9a4cc726f31ef31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28669d70bc0b5786c08d8a612f8f7d1d0aaf69e75c258e544cc6f3aa8862833bde6cb38ba42b6a97c78ff77c865928f4889507aeb50c46c6c89df2c369251b5
|
7
|
+
data.tar.gz: 49a1bd4d91fbb131d673277a7c7f2d1fd4590282e13f9c5099b31564f5f698805c9be97370ed8f3df7f3be0dbe9c10689f7e44d0b486beeed65bfe1518fa40c2
|
data/README.md
CHANGED
@@ -9,7 +9,8 @@ Build Status: [.
|
@@ -631,8 +632,7 @@ Similar format to redis store, but array with integer values
|
|
631
632
|
|
632
633
|
### Todo
|
633
634
|
|
634
|
-
*
|
635
|
-
* move off sinatra to pure rack
|
635
|
+
* add articles / podcasts like prontos readme https://github.com/prontolabs/pronto
|
636
636
|
* graphite adapters (it would allow passing in date ranges on usage)
|
637
637
|
* perf test for array vs hash
|
638
638
|
* redis pipeline around hash (or batch get then push)
|
@@ -9,16 +9,18 @@ module Coverband
|
|
9
9
|
class MemoryCacheStore < Base
|
10
10
|
attr_accessor :store
|
11
11
|
|
12
|
+
@@files_cache = {}
|
13
|
+
|
12
14
|
def initialize(store)
|
13
15
|
@store = store
|
14
16
|
end
|
15
17
|
|
16
|
-
def self.
|
17
|
-
files_cache.clear
|
18
|
+
def self.clear!
|
19
|
+
@@files_cache.clear
|
18
20
|
end
|
19
21
|
|
20
22
|
def clear!
|
21
|
-
self.class.
|
23
|
+
self.class.clear!
|
22
24
|
end
|
23
25
|
|
24
26
|
def save_report(files)
|
@@ -26,28 +28,26 @@ module Coverband
|
|
26
28
|
store.save_report(filtered_files) if filtered_files.any?
|
27
29
|
end
|
28
30
|
|
29
|
-
# rubocop:disable Lint/IneffectiveAccessModifier
|
30
31
|
private
|
31
32
|
|
32
|
-
def self.files_cache
|
33
|
-
@files_cache ||= {}
|
34
|
-
end
|
35
|
-
|
36
33
|
def files_cache
|
37
|
-
|
34
|
+
@@files_cache
|
38
35
|
end
|
39
36
|
|
40
37
|
def filter(files)
|
41
|
-
files.each_with_object({}) do |(file,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
line_cache.include?(line) ? true : (line_cache << line && false)
|
38
|
+
files.each_with_object({}) do |(file, covered_lines), filtered_file_hash|
|
39
|
+
if covered_lines != cached_file(file)
|
40
|
+
files_cache[file] = covered_lines
|
41
|
+
filtered_file_hash[file] = covered_lines
|
46
42
|
end
|
47
|
-
filtered_file_hash[file] = lines if lines.any?
|
48
43
|
end
|
49
44
|
end
|
50
|
-
|
45
|
+
|
46
|
+
def cached_file(file)
|
47
|
+
files_cache[file] ||= store.covered_lines_for_file(file).each_with_object({}) do |(line_number, value), hash|
|
48
|
+
hash[line_number.to_i] = value.to_i
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -71,7 +71,7 @@ module Coverband
|
|
71
71
|
@store = Coverband::Adapters::RedisStore.new(redis, ttl: Coverband.configuration.redis_ttl,
|
72
72
|
redis_namespace: Coverband.configuration.redis_namespace)
|
73
73
|
elsif store.is_a?(String)
|
74
|
-
@store = Coverband::Adapters::FileStore.new(
|
74
|
+
@store = Coverband::Adapters::FileStore.new(store)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -20,6 +20,8 @@ module Coverband
|
|
20
20
|
|
21
21
|
if request.post?
|
22
22
|
case request.path_info
|
23
|
+
when /\/collect_update_and_view/
|
24
|
+
collect_update_and_view
|
23
25
|
when /\/clear/
|
24
26
|
clear
|
25
27
|
when /\/update_report/
|
@@ -51,6 +53,7 @@ module Coverband
|
|
51
53
|
html += "<strong>Notice:</strong> #{Rack::Utils.escape_html(request.params['notice'])}<br/>" if request.params['notice']
|
52
54
|
html += "<ul>"
|
53
55
|
html += "<li><a href='#{base_path}'>Coverband Web Admin Index</a></li>"
|
56
|
+
html += "<li>#{button("#{base_path}collect_update_and_view",'collect data, update report, & view')}</li>"
|
54
57
|
html += "<li><a href='#{base_path}show'>view coverage report</a></li>"
|
55
58
|
html += "<li>#{button("#{base_path}collect_coverage",'update coverage data (collect coverage)')}</li>"
|
56
59
|
html += "<li>#{button("#{base_path}update_report",'update coverage report (rebuild report)')}</li>"
|
@@ -74,6 +77,12 @@ module Coverband
|
|
74
77
|
html
|
75
78
|
end
|
76
79
|
|
80
|
+
def collect_update_and_view
|
81
|
+
collect_coverage
|
82
|
+
update_report
|
83
|
+
[301, { 'Location' => "#{base_path}show" }, []]
|
84
|
+
end
|
85
|
+
|
77
86
|
def update_report
|
78
87
|
Coverband::Reporters::SimpleCovReport.report(Coverband.configuration.store, open_report: false)
|
79
88
|
notice = 'coverband coverage updated'
|
data/lib/coverband/version.rb
CHANGED
@@ -5,52 +5,62 @@ require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
5
5
|
module Coverband
|
6
6
|
class MemoryCacheStoreTest < Test::Unit::TestCase
|
7
7
|
def setup
|
8
|
-
Adapters::MemoryCacheStore.
|
9
|
-
@
|
8
|
+
Adapters::MemoryCacheStore.clear!
|
9
|
+
@redis = Redis.new
|
10
|
+
@store = Coverband::Adapters::RedisStore.new(@redis)
|
11
|
+
@store.clear!
|
10
12
|
@memory_store = Adapters::MemoryCacheStore.new(@store)
|
11
13
|
end
|
12
14
|
|
13
|
-
def data
|
14
|
-
{
|
15
|
-
'file1' => { 3 => 1, 5 => 2 },
|
16
|
-
'file2' => { 1 => 1, 2 => 1 }
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
15
|
test 'it passes data into store' do
|
16
|
+
data = {
|
17
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
18
|
+
'file2' => { 1 => 5, 2 => 2 }
|
19
|
+
}
|
21
20
|
@store.expects(:save_report).with data
|
22
|
-
@store.expects(:covered_lines_for_file).with('file1').returns []
|
23
|
-
@store.expects(:covered_lines_for_file).with('file2').returns []
|
24
21
|
@memory_store.save_report data
|
25
22
|
end
|
26
23
|
|
27
|
-
|
24
|
+
|
25
|
+
test 'it filters coverage with same exact data' do
|
26
|
+
data = {
|
27
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
28
|
+
'file2' => { 1 => 5, 2 => 2 }
|
29
|
+
}
|
28
30
|
@store.expects(:save_report).once.with data
|
29
|
-
@store.expects(:covered_lines_for_file).with('file1').returns []
|
30
|
-
@store.expects(:covered_lines_for_file).with('file2').returns []
|
31
31
|
2.times { @memory_store.save_report data }
|
32
32
|
end
|
33
|
+
|
34
|
+
test 'it filters coverage for files with same exact data' do
|
35
|
+
|
36
|
+
report_first_request = {
|
37
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
38
|
+
'file2' => { 1 => 5, 2 => 2 }
|
39
|
+
}
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
'
|
37
|
-
'file2' => { 1 => 1, 2 => 1 }
|
41
|
+
report_second_request = {
|
42
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
43
|
+
'file2' => { 1 => 5, 2 => 3 }
|
38
44
|
}
|
39
|
-
@store.expects(:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@memory_store.save_report
|
45
|
+
@store.expects(:save_report).with({
|
46
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
47
|
+
'file2' => { 1 => 5, 2 => 2 }
|
48
|
+
})
|
49
|
+
@store.expects(:save_report).with({
|
50
|
+
'file2' => { 1 => 5, 2 => 3 }
|
51
|
+
})
|
52
|
+
@memory_store.save_report(report_first_request)
|
53
|
+
@memory_store.save_report(report_second_request)
|
47
54
|
end
|
48
55
|
|
49
56
|
test 'it initializes cache with what is in store' do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
data = {
|
58
|
+
'file1' => { 1 => 0, 2 => 1, 3 => 0 },
|
59
|
+
'file2' => { 1 => 5, 2 => 2 }
|
60
|
+
}
|
61
|
+
Coverband::Adapters::RedisStore.new(@redis).save_report(data)
|
62
|
+
@store.expects(:save_report).never
|
63
|
+
@memory_store.save_report(data)
|
54
64
|
end
|
55
65
|
end
|
56
66
|
end
|
@@ -7,29 +7,31 @@ require 'rack/test'
|
|
7
7
|
|
8
8
|
ENV['RACK_ENV'] = 'test'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
|
11
|
+
module Coverband
|
12
|
+
class S3WebTest < Test::Unit::TestCase
|
13
|
+
include Rack::Test::Methods
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def app
|
16
|
+
Coverband::Reporters::Web.new
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
# TODO add tests for all endpoints
|
20
|
+
test 'renders index content' do
|
21
|
+
get '/'
|
22
|
+
assert last_response.ok?
|
23
|
+
assert_match 'Coverband Web Admin Index', last_response.body
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
test 'renders show content' do
|
27
|
+
Coverband.configuration.s3_bucket = 'coverage-bucket'
|
28
|
+
s3 = mock('s3')
|
29
|
+
Aws::S3::Client.expects(:new).returns(s3)
|
30
|
+
s3.expects(:get_object).with(bucket: 'coverage-bucket', key: 'coverband/index.html').returns mock('response', body: mock('body', read: 'content'))
|
31
|
+
get '/show'
|
32
|
+
assert last_response.ok?
|
33
|
+
assert_equal 'content', last_response.body
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
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: 2.0.2.
|
4
|
+
version: 2.0.2.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|