coverband 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +4 -1
- data/.travis.yml +4 -2
- data/README.md +24 -8
- data/Rakefile +1 -1
- data/changes.md +17 -24
- data/coverband.gemspec +4 -0
- data/lib/coverband/adapters/redis_store.rb +1 -1
- data/lib/coverband/collectors/coverage.rb +7 -1
- data/lib/coverband/integrations/resque.rb +0 -1
- data/lib/coverband/version.rb +1 -1
- data/public/favicon.png +0 -0
- data/test/benchmarks/benchmark.rake +31 -0
- data/test/benchmarks/coverage_fork.sh +37 -0
- data/test/{unit/adapters_base_test.rb → coverband/adapters/base_test.rb} +1 -1
- data/test/{unit/adapters_file_store_test.rb → coverband/adapters/file_store_test.rb} +1 -1
- data/test/{unit/adapters_redis_store_test.rb → coverband/adapters/redis_store_test.rb} +1 -1
- data/test/{unit → coverband}/at_exit_test.rb +0 -0
- data/test/coverband/collectors/coverage_test.rb +67 -0
- data/test/{unit → coverband}/configuration_test.rb +0 -0
- data/test/{unit → coverband}/coverband_test.rb +0 -0
- data/test/{unit → coverband/integrations}/background_test.rb +1 -1
- data/test/{unit → coverband/integrations}/middleware_test.rb +1 -1
- data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb} +1 -1
- data/test/{unit → coverband/integrations}/resque_worker_test.rb +2 -2
- data/test/{unit → coverband/integrations}/test_resque_job.rb +0 -0
- data/test/{unit/reports_base_test.rb → coverband/reporters/base_test.rb} +1 -1
- data/test/{unit/reports_console_test.rb → coverband/reporters/console_test.rb} +1 -1
- data/test/{unit/reports_html_test.rb → coverband/reporters/html_test.rb} +1 -1
- data/test/{unit/reports_web_test.rb → coverband/reporters/web_test.rb} +2 -2
- data/test/{unit → coverband}/utils/file_groups_test.rb +0 -0
- data/test/{unit → coverband}/utils/file_list_test.rb +0 -0
- data/test/{unit → coverband}/utils/gem_list_test.rb +0 -0
- data/test/{unit → coverband}/utils/lines_classifier_test.rb +0 -0
- data/test/{unit → coverband}/utils/result_test.rb +0 -0
- data/test/{unit → coverband}/utils/s3_report_test.rb +0 -0
- data/test/{unit → coverband}/utils/source_file_line_test.rb +0 -0
- data/test/{unit → coverband}/utils/source_file_test.rb +0 -0
- data/test/{unit/dog.rb → dog.rb} +0 -0
- data/test/{unit → integration}/full_stack_test.rb +0 -0
- data/test/{unit → integration}/rails_full_stack_test.rb +0 -0
- data/test/{unit → integration}/rails_gems_full_stack_test.rb +0 -0
- data/test/rails4_dummy/tmp/.keep +0 -0
- data/test/rails5_dummy/tmp/.keep +0 -0
- data/test/test_helper.rb +1 -12
- data/test/unique_files.rb +23 -0
- metadata +96 -59
- data/test/unit/collectors_coverage_test.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e029eb4a5ce229ca0ce9dd7ac6638bc3b9776e07a724269a495b2832228119d
|
4
|
+
data.tar.gz: 0f37d401fafe727024665b096e337138e53f8be139521dea9e149695b44f39ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0d51d0263c37369abffc5839a367cdebd5fad7d8132362044163614fca33e2bc8617770bb36d3dd268eb34a4f0243e5fe4a1fad516f724a9da122aa5739a8be
|
7
|
+
data.tar.gz: db40dfd936b39d159e7d92b470b186761cfea6ce944e55ff8079d70279af8c84a3602c5c873317c58d76b08aa0a654e653eb10df8a608ba646e4bd37b006105b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,7 +3,7 @@ rvm:
|
|
3
3
|
- "2.3"
|
4
4
|
- "2.4"
|
5
5
|
- "2.5"
|
6
|
-
- "2.6"
|
6
|
+
- "2.6.1"
|
7
7
|
gemfile:
|
8
8
|
- Gemfile
|
9
9
|
- Gemfile.rails4
|
@@ -11,7 +11,9 @@ services:
|
|
11
11
|
- redis-server
|
12
12
|
before_install:
|
13
13
|
- echo 'this is a hack to clear default bundler and force bundler 1.17.3'
|
14
|
+
- ls /home/travis/.rvm/gems/
|
14
15
|
- rm /home/travis/.rvm/gems/ruby-2.3.7@global/specifications/bundler-2.0.1.gemspec || true
|
16
|
+
- rm /home/travis/.rvm/gems/ruby-2.5.4@global/specifications/bundler-2.0.1.gemspec || true
|
15
17
|
- gem uninstall bundler || true
|
16
18
|
- gem install bundler -v '1.17.3'
|
17
|
-
- bundler --version
|
19
|
+
- bundler --version
|
data/README.md
CHANGED
@@ -38,6 +38,8 @@ Coverband stores coverage data in Redis. The Redis endpoint is looked for in thi
|
|
38
38
|
2. `ENV['REDIS_URL']`
|
39
39
|
3. `localhost`
|
40
40
|
|
41
|
+
The redis store can also be explicitly defined within the coverband.rb. See [advanced config](#advanced-config).
|
42
|
+
|
41
43
|
## Gem Installation
|
42
44
|
|
43
45
|
Add this line to your application's `Gemfile`, remember to `bundle install` after updating:
|
@@ -46,9 +48,11 @@ Add this line to your application's `Gemfile`, remember to `bundle install` afte
|
|
46
48
|
gem 'coverband'
|
47
49
|
```
|
48
50
|
|
51
|
+
If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
|
52
|
+
|
49
53
|
## Rails
|
50
54
|
|
51
|
-
The Railtie integration means you shouldn't need to do anything anything else
|
55
|
+
The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile.
|
52
56
|
|
53
57
|
|
54
58
|
## Sinatra
|
@@ -251,16 +255,28 @@ By adding any files above you will get reporting on those files as part of your
|
|
251
255
|
|
252
256
|
### Collecting Gem / Library Usage
|
253
257
|
|
254
|
-
|
258
|
+
Gem usage can be tracked by enabling the `track_gems` config.
|
259
|
+
|
260
|
+
```
|
261
|
+
Coverband.configure do |config|
|
262
|
+
config.track_gems = true
|
263
|
+
end
|
264
|
+
```
|
255
265
|
|
256
|
-
|
266
|
+
The `track_gems` feature exposes a Gems tab in the report which prints out the percentage usage of each Gem. See demo [here](https://coverband-demo.herokuapp.com/coverage?#_Gems).
|
257
267
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
268
|
+
When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. Since `Coverband#start` is automatically called by default when coverband is required, list coverband before the other gems to be tracked within your Gemfile. The exception to this are gems like rails and resque. Since coverband has some specific intergrations for these frameworks, these two gems should be required first.
|
269
|
+
|
270
|
+
The track_gems config only exposes the overall usage of a gem. In order to see the detail of each file, enable the `gem_details` flag.
|
271
|
+
|
272
|
+
```
|
273
|
+
Coverband.configure do |config|
|
274
|
+
config.track_gems = true
|
275
|
+
config.gem_details = true
|
276
|
+
end
|
277
|
+
```
|
263
278
|
|
279
|
+
This flag exposes line by line usage of gem files. Unfortunately due to the way the coverband report is currently rendered, enabling `gem_details` slows down viewing of the coverage report in the browser and is not yet recommended.
|
264
280
|
|
265
281
|
### Verbose Debug / Development Mode
|
266
282
|
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ Rake::TestTask.new(:test) do |test|
|
|
13
13
|
# exclude benchmark from the tests as the way it functions resets code coverage during executions
|
14
14
|
# test.pattern = 'test/unit/*_test.rb'
|
15
15
|
# using test files opposed to pattern as it outputs which files are run
|
16
|
-
test.test_files = FileList['test/
|
16
|
+
test.test_files = FileList['test/integration/**/*_test.rb', 'test/coverband/**/*_test.rb']
|
17
17
|
test.verbose = true
|
18
18
|
end
|
19
19
|
|
data/changes.md
CHANGED
@@ -36,7 +36,7 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
36
36
|
- Make good video on setup, install, usage
|
37
37
|
- See if we can add support for views / templates
|
38
38
|
- using this technique https://github.com/ioquatix/covered
|
39
|
-
- Better default grouping (could use groups features for gems for rails controllers, models, lib, etc)
|
39
|
+
- Better default grouping (could use groups features for gems for rails controllers, models, lib, etc)
|
40
40
|
|
41
41
|
### Coverband_jam_session
|
42
42
|
|
@@ -63,27 +63,23 @@ Feature Ideas:
|
|
63
63
|
|
64
64
|
# Alpha
|
65
65
|
|
66
|
-
### Coverband 4.2.0.
|
66
|
+
### Coverband 4.2.0.rc
|
67
67
|
|
68
|
-
|
68
|
+
- loadtime vs runtime coverage
|
69
|
+
- view coverage
|
70
|
+
- perf speedup on gem details views
|
69
71
|
|
70
|
-
|
72
|
+
# Released
|
71
73
|
|
72
|
-
|
73
|
-
- out of the box support for resque
|
74
|
-
- readme improvements
|
75
|
-
- fix on regression of merging directory changing deployments
|
76
|
-
- fixes for duplicate root paths
|
77
|
-
- pilot release of Gems tracking (disabled by default)
|
78
|
-
- todos
|
79
|
-
- support multiple gem paths (various version managers setup multiple gem paths)
|
80
|
-
- speed up page load by allowing multiple pages
|
81
|
-
- added web settings and debug views
|
82
|
-
- added support for seeing coverage data size consumed in redis
|
83
|
-
- support coverage data migrations from 4.0.x to 4.1.0
|
84
|
-
- fixes for heroku /tmp asset building
|
74
|
+
### Coverband 4.1.1
|
85
75
|
|
86
|
-
|
76
|
+
- fix bug on info page when using namespaces
|
77
|
+
- fix bug related to forking Ruby processes (Resque for example)
|
78
|
+
- bug caused negative line hits
|
79
|
+
- bug seemed to cause memory leaks (not entirely sure how)
|
80
|
+
- various test improvements
|
81
|
+
- fix bad requests on coverband web admin to `/coverage/favicon.png`
|
82
|
+
- improved documentation
|
87
83
|
|
88
84
|
### Coverband 4.1.0
|
89
85
|
|
@@ -91,13 +87,10 @@ Feature Ideas:
|
|
91
87
|
- out of the box support for resque
|
92
88
|
- readme improvements
|
93
89
|
- fix on regression of merging directory changing deployments
|
94
|
-
- fixes for duplicate root paths
|
95
|
-
- pilot release of Gems tracking (disabled by default)
|
96
|
-
- todos
|
97
|
-
- support multiple gem paths (various version managers setup multiple gem paths)
|
98
|
-
- speed up page load by allowing multiple pages
|
90
|
+
- fixes for duplicate root paths
|
91
|
+
- pilot release of Gems tracking (disabled by default) - todos - support multiple gem paths (various version managers setup multiple gem paths) - speed up page load by allowing multiple pages
|
99
92
|
- added web settings and debug views
|
100
|
-
|
93
|
+
- added support for seeing coverage data size consumed in redis
|
101
94
|
- support coverage data migrations from 4.0.x to 4.1.0
|
102
95
|
- fixes for heroku /tmp asset building
|
103
96
|
|
data/coverband.gemspec
CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'rack-test'
|
34
34
|
spec.add_development_dependency 'rake'
|
35
35
|
spec.add_development_dependency 'resque'
|
36
|
+
# temporarily needed to fun tests for classifier-reborn as part of benchmarks
|
37
|
+
spec.add_development_dependency 'minitest-reporters'
|
36
38
|
|
37
39
|
# TODO: used for benchmarking and tests I think we have other better benchmarking
|
38
40
|
# perhaps time to drop this and refactor.
|
@@ -42,6 +44,8 @@ Gem::Specification.new do |spec|
|
|
42
44
|
# require 'byebug'; byebug
|
43
45
|
spec.add_development_dependency 'pry-byebug'
|
44
46
|
|
47
|
+
spec.add_development_dependency 'minitest-profile'
|
48
|
+
|
45
49
|
# TODO: Remove when other production adapters exist
|
46
50
|
# because the default configuration of redis store, we really do require
|
47
51
|
# redis now. I was reluctant to add this, but until we offer another production
|
@@ -87,7 +87,13 @@ module Coverband
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def array_diff(latest, original)
|
90
|
-
latest.map.with_index
|
90
|
+
latest.map.with_index do |v, i|
|
91
|
+
if (v && original[i])
|
92
|
+
[0, v - original[i]].max
|
93
|
+
else
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
end
|
91
97
|
end
|
92
98
|
|
93
99
|
def previous_results
|
data/lib/coverband/version.rb
CHANGED
data/public/favicon.png
ADDED
Binary file
|
@@ -219,12 +219,43 @@ namespace :benchmarks do
|
|
219
219
|
$stdout = previous_out
|
220
220
|
end
|
221
221
|
|
222
|
+
def measure_configure_memory
|
223
|
+
require 'memory_profiler'
|
224
|
+
# warmup
|
225
|
+
3.times { Coverband.configure }
|
226
|
+
|
227
|
+
previous_out = $stdout
|
228
|
+
capture = StringIO.new
|
229
|
+
$stdout = capture
|
230
|
+
|
231
|
+
MemoryProfiler.report do
|
232
|
+
10.times do
|
233
|
+
Coverband.configure do |config|
|
234
|
+
redis_url = ENV['CACHE_REDIS_URL'] || ENV['REDIS_URL']
|
235
|
+
config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: redis_url), redis_namespace: 'coverband_data')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end.pretty_print
|
239
|
+
data = $stdout.string
|
240
|
+
$stdout = previous_out
|
241
|
+
puts data
|
242
|
+
raise 'leaking memory!!!' unless data.match('Total retained: 0 bytes')
|
243
|
+
ensure
|
244
|
+
$stdout = previous_out
|
245
|
+
end
|
246
|
+
|
222
247
|
desc 'runs memory reporting on Redis store'
|
223
248
|
task memory_reporting: [:setup] do
|
224
249
|
puts 'runs memory benchmarking to ensure we dont leak'
|
225
250
|
measure_memory
|
226
251
|
end
|
227
252
|
|
253
|
+
desc 'runs memory reporting on configure'
|
254
|
+
task memory_configure_reporting: [:setup] do
|
255
|
+
puts 'runs memory benchmarking on configure to ensure we dont leak'
|
256
|
+
measure_configure_memory
|
257
|
+
end
|
258
|
+
|
228
259
|
desc 'runs memory leak check via Rails tests'
|
229
260
|
task memory_rails: [:setup] do
|
230
261
|
puts 'runs memory rails test to ensure we dont leak'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is a small script to illustrate how previous results get wiped out by forking
|
4
|
+
# this has implications of forking processes like Resque...
|
5
|
+
# this in the end would cause coverage.array_diff
|
6
|
+
# with previous results to add NEGATIVE code hits to the stored Coverage
|
7
|
+
# which in turn causes all sorts of crazy issues.
|
8
|
+
#
|
9
|
+
# ruby test/benchmarks/coverage_fork.rb
|
10
|
+
# in parent before fork
|
11
|
+
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 1, 1, 2, nil, nil]}
|
12
|
+
# in child after fork
|
13
|
+
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 0, 0, 0, nil, nil]}
|
14
|
+
# now triggering hits
|
15
|
+
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 0, 0, 3, nil, nil]}
|
16
|
+
#
|
17
|
+
# I believe this might be related to CoW and GC... not sure
|
18
|
+
# http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
|
19
|
+
#
|
20
|
+
# NOTE: That the child now has 0 hits where previously method definitions had 1
|
21
|
+
# this causes all sorts of bad things to happen.
|
22
|
+
require 'coverage'
|
23
|
+
Coverage.start
|
24
|
+
load './test/dog.rb'
|
25
|
+
Dog.new.bark
|
26
|
+
Dog.new.bark
|
27
|
+
puts 'in parent before fork'
|
28
|
+
puts Coverage.peek_result
|
29
|
+
fork do
|
30
|
+
puts 'in child after fork'
|
31
|
+
puts Coverage.peek_result
|
32
|
+
puts 'now triggering hits'
|
33
|
+
Dog.new.bark
|
34
|
+
Dog.new.bark
|
35
|
+
Dog.new.bark
|
36
|
+
puts Coverage.peek_result
|
37
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class RedisTest < Minitest::Test
|
6
6
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
class CollectorsCoverageTest < Minitest::Test
|
6
|
+
attr_accessor :coverband
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
Coverband.configure do |config|
|
11
|
+
config.store = Coverband::Adapters::RedisStore.new(Redis.new)
|
12
|
+
end
|
13
|
+
@coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
Thread.current[:coverband_instance] = nil
|
18
|
+
Coverband.configure do |config|
|
19
|
+
end
|
20
|
+
@coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'Dog class coverage' do
|
24
|
+
file = require_unique_file
|
25
|
+
coverband.report_coverage(true)
|
26
|
+
coverage = Coverband.configuration.store.coverage
|
27
|
+
assert_equal(coverage[file]["data"], [nil, nil, 1, 1, 0, nil, nil])
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'Dog method and class coverage' do
|
31
|
+
load File.expand_path('../../dog.rb', File.dirname(__FILE__))
|
32
|
+
Dog.new.bark
|
33
|
+
coverband.report_coverage(true)
|
34
|
+
coverage = Coverband.configuration.store.coverage
|
35
|
+
assert_equal(coverage["./test/dog.rb"]["data"], [nil, nil, 1, 1, 1, nil, nil])
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'gets coverage instance' do
|
39
|
+
assert_equal Coverband::Collectors::Coverage, coverband.class
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'defaults to a redis store' do
|
43
|
+
assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get('@store').class
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'report_coverage raises errors in tests' do
|
47
|
+
@coverband.reset_instance
|
48
|
+
@coverband.expects(:ready_to_report?).raises('Oh no')
|
49
|
+
assert_raises RuntimeError do
|
50
|
+
@coverband.report_coverage
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'default tmp ignores' do
|
55
|
+
heroku_build_file = '/tmp/build_81feca8c72366e4edf020dc6f1937485/config/initializers/assets.rb'
|
56
|
+
assert_equal false, @coverband.send(:track_file?, heroku_build_file)
|
57
|
+
end
|
58
|
+
|
59
|
+
test '#array_diff never returns negative hits' do
|
60
|
+
# this can occur if a process forks after initializing the previous results
|
61
|
+
# see test/benchmarks/coverage_fork.rb
|
62
|
+
latest = [0, nil]
|
63
|
+
original = [1, nil]
|
64
|
+
expected = [0, nil]
|
65
|
+
assert_equal expected, @coverband.send(:array_diff, latest, original)
|
66
|
+
end
|
67
|
+
end
|
File without changes
|
File without changes
|
data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class RackServerCheckTest < Minitest::Test
|
6
6
|
test 'returns true when running in rack server' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class ResqueWorkerTest < Minitest::Test
|
6
6
|
def enqueue_and_run_job
|
@@ -23,7 +23,7 @@ class ResqueWorkerTest < Minitest::Test
|
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'resque job coverage' do
|
26
|
-
relative_job_file = './
|
26
|
+
relative_job_file = './integrations/test_resque_job.rb'
|
27
27
|
resque_job_file = File.expand_path('./test_resque_job.rb', File.dirname(__FILE__))
|
28
28
|
require resque_job_file
|
29
29
|
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class ReportsBaseTest < Minitest::Test
|
6
6
|
test 'relative_path_to_full fix filename from a key with a swappable path' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class HTMLReportTest < Minitest::Test
|
6
6
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class ReportHTMLTest < Minitest::Test
|
6
6
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
4
|
require 'aws-sdk-s3'
|
5
|
-
require File.expand_path('
|
5
|
+
require File.expand_path('../../../lib/coverband/reporters/web', File.dirname(__FILE__))
|
6
6
|
require 'rack/test'
|
7
7
|
|
8
8
|
ENV['RACK_ENV'] = 'test'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/{unit/dog.rb → dog.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -16,6 +16,7 @@ require 'json'
|
|
16
16
|
require 'redis'
|
17
17
|
require 'resque'
|
18
18
|
require 'pry-byebug'
|
19
|
+
require_relative 'unique_files'
|
19
20
|
$VERBOSE = original_verbosity
|
20
21
|
|
21
22
|
Coveralls.wear!
|
@@ -79,18 +80,6 @@ def basic_coverage
|
|
79
80
|
{ 'app_path/dog.rb' => example_line }
|
80
81
|
end
|
81
82
|
|
82
|
-
def fake_redis
|
83
|
-
@redis ||= begin
|
84
|
-
redis = OpenStruct.new
|
85
|
-
redis
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def fake_coverage_report
|
90
|
-
file_name = '/Users/danmayer/projects/hearno/script/tester.rb'
|
91
|
-
{ file_name => [1, nil, 1, 1, nil, nil, nil] }
|
92
|
-
end
|
93
|
-
|
94
83
|
def source_fixture(filename)
|
95
84
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
|
96
85
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
UNIQUE_FILES_DIR = "./test/unique_files"
|
7
|
+
|
8
|
+
def require_unique_file(file = 'dog.rb')
|
9
|
+
dir = "#{UNIQUE_FILES_DIR}/#{SecureRandom.uuid}"
|
10
|
+
FileUtils.mkdir_p(dir)
|
11
|
+
temp_file = "#{dir}/#{file}"
|
12
|
+
File.open(temp_file, 'w'){ |w| w.write(File.read("./test/#{file}")) }
|
13
|
+
require temp_file
|
14
|
+
temp_file
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove_unique_files
|
18
|
+
FileUtils.rm_r(UNIQUE_FILES_DIR) if File.exist?(UNIQUE_FILES_DIR)
|
19
|
+
end
|
20
|
+
|
21
|
+
Minitest.after_run do
|
22
|
+
remove_unique_files
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-s3
|
@@ -165,6 +165,20 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: minitest-reporters
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
168
182
|
- !ruby/object:Gem::Dependency
|
169
183
|
name: classifier-reborn
|
170
184
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,6 +221,20 @@ dependencies:
|
|
207
221
|
- - ">="
|
208
222
|
- !ruby/object:Gem::Version
|
209
223
|
version: '0'
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: minitest-profile
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
210
238
|
- !ruby/object:Gem::Dependency
|
211
239
|
name: redis
|
212
240
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,6 +301,7 @@ files:
|
|
273
301
|
- public/colorbox/controls.png
|
274
302
|
- public/colorbox/loading.gif
|
275
303
|
- public/colorbox/loading_background.png
|
304
|
+
- public/favicon.png
|
276
305
|
- public/favicon_green.png
|
277
306
|
- public/favicon_red.png
|
278
307
|
- public/favicon_yellow.png
|
@@ -293,8 +322,34 @@ files:
|
|
293
322
|
- public/magnify.png
|
294
323
|
- test/benchmarks/.gitignore
|
295
324
|
- test/benchmarks/benchmark.rake
|
325
|
+
- test/benchmarks/coverage_fork.sh
|
296
326
|
- test/benchmarks/dog.rb
|
297
327
|
- test/benchmarks/graph_bench.sh
|
328
|
+
- test/coverband/adapters/base_test.rb
|
329
|
+
- test/coverband/adapters/file_store_test.rb
|
330
|
+
- test/coverband/adapters/redis_store_test.rb
|
331
|
+
- test/coverband/at_exit_test.rb
|
332
|
+
- test/coverband/collectors/coverage_test.rb
|
333
|
+
- test/coverband/configuration_test.rb
|
334
|
+
- test/coverband/coverband_test.rb
|
335
|
+
- test/coverband/integrations/background_test.rb
|
336
|
+
- test/coverband/integrations/middleware_test.rb
|
337
|
+
- test/coverband/integrations/rack_server_check_test.rb
|
338
|
+
- test/coverband/integrations/resque_worker_test.rb
|
339
|
+
- test/coverband/integrations/test_resque_job.rb
|
340
|
+
- test/coverband/reporters/base_test.rb
|
341
|
+
- test/coverband/reporters/console_test.rb
|
342
|
+
- test/coverband/reporters/html_test.rb
|
343
|
+
- test/coverband/reporters/web_test.rb
|
344
|
+
- test/coverband/utils/file_groups_test.rb
|
345
|
+
- test/coverband/utils/file_list_test.rb
|
346
|
+
- test/coverband/utils/gem_list_test.rb
|
347
|
+
- test/coverband/utils/lines_classifier_test.rb
|
348
|
+
- test/coverband/utils/result_test.rb
|
349
|
+
- test/coverband/utils/s3_report_test.rb
|
350
|
+
- test/coverband/utils/source_file_line_test.rb
|
351
|
+
- test/coverband/utils/source_file_test.rb
|
352
|
+
- test/dog.rb
|
298
353
|
- test/fake_app/basic_rack.rb
|
299
354
|
- test/fixtures/app/controllers/sample_controller.rb
|
300
355
|
- test/fixtures/app/models/user.rb
|
@@ -303,6 +358,9 @@ files:
|
|
303
358
|
- test/fixtures/skipped.rb
|
304
359
|
- test/fixtures/skipped_and_executed.rb
|
305
360
|
- test/fixtures/utf-8.rb
|
361
|
+
- test/integration/full_stack_test.rb
|
362
|
+
- test/integration/rails_full_stack_test.rb
|
363
|
+
- test/integration/rails_gems_full_stack_test.rb
|
306
364
|
- test/rails4_dummy/app/controllers/dummy_controller.rb
|
307
365
|
- test/rails4_dummy/config.ru
|
308
366
|
- test/rails4_dummy/config/application.rb
|
@@ -311,42 +369,17 @@ files:
|
|
311
369
|
- test/rails4_dummy/config/environment.rb
|
312
370
|
- test/rails4_dummy/config/routes.rb
|
313
371
|
- test/rails4_dummy/config/secrets.yml
|
372
|
+
- test/rails4_dummy/tmp/.keep
|
314
373
|
- test/rails5_dummy/app/controllers/dummy_controller.rb
|
315
374
|
- test/rails5_dummy/config.ru
|
316
375
|
- test/rails5_dummy/config/application.rb
|
317
376
|
- test/rails5_dummy/config/coverband.rb
|
318
377
|
- test/rails5_dummy/config/environment.rb
|
319
378
|
- test/rails5_dummy/config/routes.rb
|
379
|
+
- test/rails5_dummy/tmp/.keep
|
320
380
|
- test/rails_test_helper.rb
|
321
381
|
- test/test_helper.rb
|
322
|
-
- test/
|
323
|
-
- test/unit/adapters_file_store_test.rb
|
324
|
-
- test/unit/adapters_redis_store_test.rb
|
325
|
-
- test/unit/at_exit_test.rb
|
326
|
-
- test/unit/background_test.rb
|
327
|
-
- test/unit/collectors_coverage_test.rb
|
328
|
-
- test/unit/configuration_test.rb
|
329
|
-
- test/unit/coverband_test.rb
|
330
|
-
- test/unit/dog.rb
|
331
|
-
- test/unit/full_stack_test.rb
|
332
|
-
- test/unit/middleware_test.rb
|
333
|
-
- test/unit/rack_server_checkout_test.rb
|
334
|
-
- test/unit/rails_full_stack_test.rb
|
335
|
-
- test/unit/rails_gems_full_stack_test.rb
|
336
|
-
- test/unit/reports_base_test.rb
|
337
|
-
- test/unit/reports_console_test.rb
|
338
|
-
- test/unit/reports_html_test.rb
|
339
|
-
- test/unit/reports_web_test.rb
|
340
|
-
- test/unit/resque_worker_test.rb
|
341
|
-
- test/unit/test_resque_job.rb
|
342
|
-
- test/unit/utils/file_groups_test.rb
|
343
|
-
- test/unit/utils/file_list_test.rb
|
344
|
-
- test/unit/utils/gem_list_test.rb
|
345
|
-
- test/unit/utils/lines_classifier_test.rb
|
346
|
-
- test/unit/utils/result_test.rb
|
347
|
-
- test/unit/utils/s3_report_test.rb
|
348
|
-
- test/unit/utils/source_file_line_test.rb
|
349
|
-
- test/unit/utils/source_file_test.rb
|
382
|
+
- test/unique_files.rb
|
350
383
|
- views/file_list.erb
|
351
384
|
- views/gem_list.erb
|
352
385
|
- views/layout.erb
|
@@ -372,15 +405,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
372
405
|
version: '0'
|
373
406
|
requirements: []
|
374
407
|
rubyforge_project:
|
375
|
-
rubygems_version: 2.
|
408
|
+
rubygems_version: 2.7.8
|
376
409
|
signing_key:
|
377
410
|
specification_version: 4
|
378
411
|
summary: Rack middleware to help measure production code usage (LOC runtime usage)
|
379
412
|
test_files:
|
380
413
|
- test/benchmarks/.gitignore
|
381
414
|
- test/benchmarks/benchmark.rake
|
415
|
+
- test/benchmarks/coverage_fork.sh
|
382
416
|
- test/benchmarks/dog.rb
|
383
417
|
- test/benchmarks/graph_bench.sh
|
418
|
+
- test/coverband/adapters/base_test.rb
|
419
|
+
- test/coverband/adapters/file_store_test.rb
|
420
|
+
- test/coverband/adapters/redis_store_test.rb
|
421
|
+
- test/coverband/at_exit_test.rb
|
422
|
+
- test/coverband/collectors/coverage_test.rb
|
423
|
+
- test/coverband/configuration_test.rb
|
424
|
+
- test/coverband/coverband_test.rb
|
425
|
+
- test/coverband/integrations/background_test.rb
|
426
|
+
- test/coverband/integrations/middleware_test.rb
|
427
|
+
- test/coverband/integrations/rack_server_check_test.rb
|
428
|
+
- test/coverband/integrations/resque_worker_test.rb
|
429
|
+
- test/coverband/integrations/test_resque_job.rb
|
430
|
+
- test/coverband/reporters/base_test.rb
|
431
|
+
- test/coverband/reporters/console_test.rb
|
432
|
+
- test/coverband/reporters/html_test.rb
|
433
|
+
- test/coverband/reporters/web_test.rb
|
434
|
+
- test/coverband/utils/file_groups_test.rb
|
435
|
+
- test/coverband/utils/file_list_test.rb
|
436
|
+
- test/coverband/utils/gem_list_test.rb
|
437
|
+
- test/coverband/utils/lines_classifier_test.rb
|
438
|
+
- test/coverband/utils/result_test.rb
|
439
|
+
- test/coverband/utils/s3_report_test.rb
|
440
|
+
- test/coverband/utils/source_file_line_test.rb
|
441
|
+
- test/coverband/utils/source_file_test.rb
|
442
|
+
- test/dog.rb
|
384
443
|
- test/fake_app/basic_rack.rb
|
385
444
|
- test/fixtures/app/controllers/sample_controller.rb
|
386
445
|
- test/fixtures/app/models/user.rb
|
@@ -389,6 +448,9 @@ test_files:
|
|
389
448
|
- test/fixtures/skipped.rb
|
390
449
|
- test/fixtures/skipped_and_executed.rb
|
391
450
|
- test/fixtures/utf-8.rb
|
451
|
+
- test/integration/full_stack_test.rb
|
452
|
+
- test/integration/rails_full_stack_test.rb
|
453
|
+
- test/integration/rails_gems_full_stack_test.rb
|
392
454
|
- test/rails4_dummy/app/controllers/dummy_controller.rb
|
393
455
|
- test/rails4_dummy/config.ru
|
394
456
|
- test/rails4_dummy/config/application.rb
|
@@ -397,39 +459,14 @@ test_files:
|
|
397
459
|
- test/rails4_dummy/config/environment.rb
|
398
460
|
- test/rails4_dummy/config/routes.rb
|
399
461
|
- test/rails4_dummy/config/secrets.yml
|
462
|
+
- test/rails4_dummy/tmp/.keep
|
400
463
|
- test/rails5_dummy/app/controllers/dummy_controller.rb
|
401
464
|
- test/rails5_dummy/config.ru
|
402
465
|
- test/rails5_dummy/config/application.rb
|
403
466
|
- test/rails5_dummy/config/coverband.rb
|
404
467
|
- test/rails5_dummy/config/environment.rb
|
405
468
|
- test/rails5_dummy/config/routes.rb
|
469
|
+
- test/rails5_dummy/tmp/.keep
|
406
470
|
- test/rails_test_helper.rb
|
407
471
|
- test/test_helper.rb
|
408
|
-
- test/
|
409
|
-
- test/unit/adapters_file_store_test.rb
|
410
|
-
- test/unit/adapters_redis_store_test.rb
|
411
|
-
- test/unit/at_exit_test.rb
|
412
|
-
- test/unit/background_test.rb
|
413
|
-
- test/unit/collectors_coverage_test.rb
|
414
|
-
- test/unit/configuration_test.rb
|
415
|
-
- test/unit/coverband_test.rb
|
416
|
-
- test/unit/dog.rb
|
417
|
-
- test/unit/full_stack_test.rb
|
418
|
-
- test/unit/middleware_test.rb
|
419
|
-
- test/unit/rack_server_checkout_test.rb
|
420
|
-
- test/unit/rails_full_stack_test.rb
|
421
|
-
- test/unit/rails_gems_full_stack_test.rb
|
422
|
-
- test/unit/reports_base_test.rb
|
423
|
-
- test/unit/reports_console_test.rb
|
424
|
-
- test/unit/reports_html_test.rb
|
425
|
-
- test/unit/reports_web_test.rb
|
426
|
-
- test/unit/resque_worker_test.rb
|
427
|
-
- test/unit/test_resque_job.rb
|
428
|
-
- test/unit/utils/file_groups_test.rb
|
429
|
-
- test/unit/utils/file_list_test.rb
|
430
|
-
- test/unit/utils/gem_list_test.rb
|
431
|
-
- test/unit/utils/lines_classifier_test.rb
|
432
|
-
- test/unit/utils/result_test.rb
|
433
|
-
- test/unit/utils/s3_report_test.rb
|
434
|
-
- test/unit/utils/source_file_line_test.rb
|
435
|
-
- test/unit/utils/source_file_test.rb
|
472
|
+
- test/unique_files.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
4
|
-
require File.expand_path('./dog', File.dirname(__FILE__))
|
5
|
-
|
6
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
|
7
|
-
class CollectorsCoverageTest < Minitest::Test
|
8
|
-
attr_accessor :coverband
|
9
|
-
|
10
|
-
def setup
|
11
|
-
super
|
12
|
-
Coverband.configure do |config|
|
13
|
-
config.store = Coverband::Adapters::RedisStore.new(Redis.new)
|
14
|
-
end
|
15
|
-
@coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
Thread.current[:coverband_instance] = nil
|
20
|
-
Coverband.configure do |config|
|
21
|
-
end
|
22
|
-
@coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'gets coverage instance' do
|
26
|
-
assert_equal Coverband::Collectors::Coverage, coverband.class
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'defaults to a redis store' do
|
30
|
-
assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get('@store').class
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'report_coverage raises errors in tests' do
|
34
|
-
@coverband.reset_instance
|
35
|
-
@coverband.expects(:ready_to_report?).raises('Oh no')
|
36
|
-
assert_raises RuntimeError do
|
37
|
-
@coverband.report_coverage
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
test 'report_coverage does not raise errors in non-test mode' do
|
42
|
-
Coverband.configuration.stubs(:test_env).returns(false)
|
43
|
-
@coverband.expects(:ready_to_report?).raises('Oh no')
|
44
|
-
@coverband.reset_instance
|
45
|
-
@coverband.report_coverage
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'default tmp ignores' do
|
49
|
-
heroku_build_file = '/tmp/build_81feca8c72366e4edf020dc6f1937485/config/initializers/assets.rb'
|
50
|
-
assert_equal false, @coverband.send(:track_file?, heroku_build_file)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|