coverband 4.2.7.rc.1 → 5.0.0.rc.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +26 -0
- data/.travis.yml +2 -1
- data/Gemfile +5 -7
- data/Gemfile.rails4 +0 -3
- data/Gemfile.rails6 +0 -3
- data/README.md +8 -77
- data/Rakefile +17 -17
- data/changes.md +30 -28
- data/config.ru +1 -1
- data/coverband.gemspec +31 -34
- data/lib/coverband.rb +68 -44
- data/lib/coverband/adapters/base.rb +17 -18
- data/lib/coverband/adapters/file_store.rb +38 -6
- data/lib/coverband/adapters/hash_redis_store.rb +24 -21
- data/lib/coverband/adapters/redis_store.rb +12 -12
- data/lib/coverband/adapters/stdout_store.rb +41 -0
- data/lib/coverband/adapters/web_service_store.rb +155 -0
- data/lib/coverband/at_exit.rb +1 -1
- data/lib/coverband/collectors/coverage.rb +15 -27
- data/lib/coverband/collectors/delta.rb +29 -9
- data/lib/coverband/collectors/view_tracker.rb +10 -10
- data/lib/coverband/collectors/view_tracker_service.rb +59 -0
- data/lib/coverband/configuration.rb +149 -112
- data/lib/coverband/integrations/background.rb +6 -6
- data/lib/coverband/integrations/rack_server_check.rb +3 -3
- data/lib/coverband/integrations/resque.rb +2 -2
- data/lib/coverband/reporters/base.rb +11 -12
- data/lib/coverband/reporters/console_report.rb +1 -1
- data/lib/coverband/reporters/html_report.rb +10 -30
- data/lib/coverband/reporters/web.rb +55 -50
- data/lib/coverband/utils/absolute_file_converter.rb +6 -6
- data/lib/coverband/utils/html_formatter.rb +32 -61
- data/lib/coverband/utils/railtie.rb +23 -6
- data/lib/coverband/utils/relative_file_converter.rb +2 -2
- data/lib/coverband/utils/result.rb +6 -11
- data/lib/coverband/utils/results.rb +0 -10
- data/lib/coverband/utils/source_file.rb +21 -30
- data/lib/coverband/utils/tasks.rb +8 -11
- data/lib/coverband/version.rb +1 -1
- data/public/application.js +0 -30
- data/test/benchmarks/benchmark.rake +97 -92
- data/test/benchmarks/dog.rb +1 -1
- data/test/benchmarks/init_rails.rake +4 -4
- data/test/coverband/adapters/base_test.rb +29 -30
- data/test/coverband/adapters/file_store_test.rb +19 -20
- data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
- data/test/coverband/adapters/redis_store_test.rb +26 -26
- data/test/coverband/adapters/web_service_store_test.rb +56 -0
- data/test/coverband/at_exit_test.rb +2 -2
- data/test/coverband/collectors/coverage_test.rb +33 -47
- data/test/coverband/collectors/delta_test.rb +52 -23
- data/test/coverband/collectors/view_tracker_test.rb +35 -35
- data/test/coverband/configuration_test.rb +49 -36
- data/test/coverband/coverband_test.rb +11 -11
- data/test/coverband/integrations/background_middleware_test.rb +10 -10
- data/test/coverband/integrations/background_test.rb +17 -5
- data/test/coverband/integrations/rack_server_check_test.rb +7 -7
- data/test/coverband/integrations/report_middleware_test.rb +9 -9
- data/test/coverband/integrations/resque_worker_test.rb +9 -9
- data/test/coverband/integrations/test_resque_job.rb +1 -1
- data/test/coverband/reporters/base_test.rb +9 -9
- data/test/coverband/reporters/console_test.rb +6 -6
- data/test/coverband/reporters/html_test.rb +36 -48
- data/test/coverband/reporters/web_test.rb +16 -18
- data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
- data/test/coverband/utils/file_hasher_test.rb +6 -12
- data/test/coverband/utils/file_list_test.rb +13 -13
- data/test/coverband/utils/html_formatter_test.rb +9 -23
- data/test/coverband/utils/lines_classifier_test.rb +29 -29
- data/test/coverband/utils/relative_file_converter_test.rb +13 -13
- data/test/coverband/utils/result_test.rb +18 -18
- data/test/coverband/utils/results_test.rb +17 -17
- data/test/coverband/utils/source_file_line_test.rb +46 -46
- data/test/coverband/utils/source_file_test.rb +38 -88
- data/test/dog.rb +1 -1
- data/test/fake_app/basic_rack.rb +2 -2
- data/test/fixtures/app/controllers/sample_controller.rb +1 -1
- data/test/fixtures/app/models/user.rb +1 -1
- data/test/fixtures/sample.rb +1 -1
- data/test/fixtures/utf-8.rb +0 -2
- data/test/forked/rails_full_stack_test.rb +24 -27
- data/test/forked/rails_rake_full_stack_test.rb +7 -26
- data/test/integration/full_stack_test.rb +11 -22
- data/test/jruby_check.rb +2 -3
- data/test/rails4_dummy/Rakefile +1 -1
- data/test/rails4_dummy/config.ru +1 -1
- data/test/rails4_dummy/config/application.rb +4 -4
- data/test/rails4_dummy/config/boot.rb +2 -2
- data/test/rails4_dummy/config/coverband.rb +1 -1
- data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
- data/test/rails4_dummy/config/environment.rb +1 -1
- data/test/rails4_dummy/config/routes.rb +2 -2
- data/test/rails5_dummy/Rakefile +1 -1
- data/test/rails5_dummy/config.ru +1 -1
- data/test/rails5_dummy/config/application.rb +3 -3
- data/test/rails5_dummy/config/coverband.rb +8 -8
- data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
- data/test/rails5_dummy/config/environment.rb +1 -1
- data/test/rails5_dummy/config/routes.rb +2 -2
- data/test/rails6_dummy/Rakefile +1 -1
- data/test/rails6_dummy/config.ru +1 -1
- data/test/rails6_dummy/config/application.rb +4 -4
- data/test/rails6_dummy/config/boot.rb +2 -2
- data/test/rails6_dummy/config/coverband.rb +1 -1
- data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
- data/test/rails6_dummy/config/environment.rb +1 -1
- data/test/rails6_dummy/config/routes.rb +2 -2
- data/test/rails_test_helper.rb +11 -11
- data/test/test_helper.rb +44 -34
- data/test/unique_files.rb +10 -10
- data/views/layout.erb +2 -12
- metadata +27 -33
- data/.rubocop.yml +0 -84
- data/lib/coverband/integrations/bundler.rb +0 -8
- data/lib/coverband/utils/file_groups.rb +0 -53
- data/lib/coverband/utils/gem_list.rb +0 -31
- data/lib/coverband/utils/s3_report.rb +0 -105
- data/test/coverband/utils/file_groups_test.rb +0 -61
- data/test/coverband/utils/gem_list_test.rb +0 -48
- data/test/coverband/utils/s3_report_test.rb +0 -44
- data/views/gem_list.erb +0 -63
data/test/benchmarks/dog.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "rails"
|
4
|
+
require "coverband"
|
5
5
|
|
6
|
-
desc
|
7
|
-
task
|
6
|
+
desc "Initialize rails"
|
7
|
+
task "init_rails" do
|
8
8
|
Coverband.configure("./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb")
|
9
9
|
require "./test/rails#{Rails::VERSION::MAJOR}_dummy/config/environment"
|
10
10
|
end
|
@@ -1,11 +1,10 @@
|
|
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 AdaptersBaseTest < Minitest::Test
|
6
|
-
|
7
6
|
def test_abstract_methods
|
8
|
-
abstract_methods = %w
|
7
|
+
abstract_methods = %w[clear! clear_file! migrate! size save_coverage coverage]
|
9
8
|
abstract_methods.each do |method|
|
10
9
|
assert_raises RuntimeError do
|
11
10
|
Coverband::Adapters::Base.new.send(method.to_sym)
|
@@ -32,10 +31,10 @@ class AdaptersBaseTest < Minitest::Test
|
|
32
31
|
assert_equal [1, 1, nil, nil], Coverband::Adapters::Base.new.send(:array_add, latest, original)
|
33
32
|
end
|
34
33
|
|
35
|
-
describe
|
34
|
+
describe "Coverband::Adapters::Base using file" do
|
36
35
|
def setup
|
37
36
|
super
|
38
|
-
@test_file_path =
|
37
|
+
@test_file_path = "/tmp/coverband_filestore_test_path.json"
|
39
38
|
@store = Coverband::Adapters::FileStore.new(@test_file_path)
|
40
39
|
mock_file_hash
|
41
40
|
end
|
@@ -44,37 +43,37 @@ class AdaptersBaseTest < Minitest::Test
|
|
44
43
|
old_time = 1541958097
|
45
44
|
current_time = Time.now.to_i
|
46
45
|
old_data = {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
"first_updated_at" => old_time,
|
47
|
+
"last_updated_at" => current_time,
|
48
|
+
"file_hash" => "abcd",
|
49
|
+
"data" => [5, 7, nil]
|
51
50
|
}
|
52
|
-
old_report = {
|
53
|
-
|
54
|
-
|
55
|
-
new_report = {
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
old_report = {"/projects/coverband_demo/config/coverband.rb" => old_data,
|
52
|
+
"/projects/coverband_demo/config/initializers/assets.rb" => old_data,
|
53
|
+
"/projects/coverband_demo/config/initializers/cookies_serializer.rb" => old_data}
|
54
|
+
new_report = {"/projects/coverband_demo/config/coverband.rb" => [5, 7, nil],
|
55
|
+
"/projects/coverband_demo/config/initializers/filter_logging.rb" => [5, 7, nil],
|
56
|
+
"/projects/coverband_demo/config/initializers/wrap_parameters.rb" => [5, 7, nil],
|
57
|
+
"/projects/coverband_demo/app/controllers/application_controller.rb" => [5, 7, nil]}
|
59
58
|
expected_merge = {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
"first_updated_at" => old_time,
|
60
|
+
"last_updated_at" => current_time,
|
61
|
+
"file_hash" => "abcd",
|
62
|
+
"data" => [10, 14, nil]
|
64
63
|
}
|
65
64
|
new_data = {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
"first_updated_at" => current_time,
|
66
|
+
"last_updated_at" => current_time,
|
67
|
+
"file_hash" => "abcd",
|
68
|
+
"data" => [5, 7, nil]
|
70
69
|
}
|
71
70
|
expected_result = {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
"/projects/coverband_demo/app/controllers/application_controller.rb" => new_data,
|
72
|
+
"/projects/coverband_demo/config/coverband.rb" => expected_merge,
|
73
|
+
"/projects/coverband_demo/config/initializers/assets.rb" => old_data,
|
74
|
+
"/projects/coverband_demo/config/initializers/cookies_serializer.rb" => old_data,
|
75
|
+
"/projects/coverband_demo/config/initializers/filter_logging.rb" => new_data,
|
76
|
+
"/projects/coverband_demo/config/initializers/wrap_parameters.rb" => new_data
|
78
77
|
}
|
79
78
|
assert_equal expected_result, @store.send(:merge_reports, new_report, old_report)
|
80
79
|
end
|
@@ -1,38 +1,36 @@
|
|
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 AdaptersFileStoreTest < Minitest::Test
|
6
|
-
|
7
6
|
def test_covered_lines_when_no_file
|
8
|
-
@store = Coverband::Adapters::FileStore.new(
|
7
|
+
@store = Coverband::Adapters::FileStore.new("")
|
9
8
|
expected = {}
|
10
9
|
assert_equal expected, @store.coverage
|
11
10
|
end
|
12
11
|
|
13
|
-
describe
|
12
|
+
describe "Coverband::Adapters::FileStore with file" do
|
14
13
|
def setup
|
15
14
|
super
|
16
|
-
@test_file_path =
|
17
|
-
|
15
|
+
@test_file_path = "/tmp/coverband_filestore_test_path.json"
|
16
|
+
previous_file_path = "#{@test_file_path}.#{::Process.pid}"
|
17
|
+
`rm #{@test_file_path}` if File.exist?(@test_file_path)
|
18
|
+
`rm #{previous_file_path}` if File.exist?(previous_file_path)
|
19
|
+
File.open(previous_file_path, "w") { |f| f.write(test_data.to_json) }
|
18
20
|
@store = Coverband::Adapters::FileStore.new(@test_file_path)
|
19
21
|
end
|
20
22
|
|
21
|
-
def test_size
|
22
|
-
assert @store.size > 1
|
23
|
-
end
|
24
|
-
|
25
23
|
def test_coverage
|
26
|
-
assert_equal @store.coverage[
|
27
|
-
assert_equal @store.coverage[
|
24
|
+
assert_equal @store.coverage["dog.rb"]["data"][0], 1
|
25
|
+
assert_equal @store.coverage["dog.rb"]["data"][1], 2
|
28
26
|
end
|
29
27
|
|
30
28
|
def test_covered_lines_when_null
|
31
|
-
assert_nil @store.coverage[
|
29
|
+
assert_nil @store.coverage["none.rb"]
|
32
30
|
end
|
33
31
|
|
34
32
|
def test_covered_files
|
35
|
-
|
33
|
+
assert @store.covered_files.include?("dog.rb")
|
36
34
|
end
|
37
35
|
|
38
36
|
def test_clear
|
@@ -42,16 +40,17 @@ class AdaptersFileStoreTest < Minitest::Test
|
|
42
40
|
|
43
41
|
def test_save_report
|
44
42
|
mock_file_hash
|
45
|
-
@store.send(:save_report,
|
46
|
-
assert_equal @store.coverage[
|
43
|
+
@store.send(:save_report, "cat.rb" => [0, 1])
|
44
|
+
assert_equal @store.coverage["cat.rb"]["data"][1], 1
|
45
|
+
assert @store.size > 1
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_data
|
50
49
|
{
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
"dog.rb" => {"data" => [1, 2, nil],
|
51
|
+
"file_hash" => "abcd",
|
52
|
+
"first_updated_at" => 1541968729,
|
53
|
+
"last_updated_at" => 1541968729}
|
55
54
|
}
|
56
55
|
end
|
57
56
|
end
|
@@ -1,13 +1,13 @@
|
|
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 HashRedisStoreTest < Minitest::Test
|
6
6
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::HashRedisStore::REDIS_STORAGE_FORMAT_VERSION
|
7
7
|
|
8
8
|
class MockRelativeFileConverter
|
9
9
|
def self.convert(file)
|
10
|
-
file.sub(
|
10
|
+
file.sub("app_path/", "./")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -16,9 +16,9 @@ class HashRedisStoreTest < Minitest::Test
|
|
16
16
|
@redis = Coverband::Test.redis
|
17
17
|
# FIXME: remove dependency on configuration and instead pass this in as an argument
|
18
18
|
Coverband.configure do |config|
|
19
|
-
config.root_paths = [
|
19
|
+
config.root_paths = ["app_path/"]
|
20
20
|
end
|
21
|
-
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace:
|
21
|
+
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace: "coverband_test", relative_file_converter: MockRelativeFileConverter)
|
22
22
|
Coverband.configuration.store = @store
|
23
23
|
end
|
24
24
|
|
@@ -34,7 +34,7 @@ class HashRedisStoreTest < Minitest::Test
|
|
34
34
|
|
35
35
|
class UnsupportedRedis
|
36
36
|
def info
|
37
|
-
{
|
37
|
+
{"redis_version" => "2.5.0"}
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -50,46 +50,46 @@ class HashRedisStoreTest < Minitest::Test
|
|
50
50
|
mock_time(yesterday)
|
51
51
|
mock_file_hash
|
52
52
|
@store.save_report(
|
53
|
-
|
53
|
+
"app_path/dog.rb" => [0, 1, 2]
|
54
54
|
)
|
55
55
|
assert_equal(
|
56
56
|
{
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
"first_updated_at" => yesterday.to_i,
|
58
|
+
"last_updated_at" => yesterday.to_i,
|
59
|
+
"file_hash" => "abcd",
|
60
|
+
"data" => [0, 1, 2]
|
61
61
|
},
|
62
|
-
@store.coverage[
|
62
|
+
@store.coverage["./dog.rb"]
|
63
63
|
)
|
64
64
|
mock_time(today)
|
65
65
|
@store.save_report(
|
66
|
-
|
66
|
+
"app_path/dog.rb" => [1, 1, 0]
|
67
67
|
)
|
68
68
|
assert_equal(
|
69
69
|
{
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
"first_updated_at" => yesterday.to_i,
|
71
|
+
"last_updated_at" => today.to_i,
|
72
|
+
"file_hash" => "abcd",
|
73
|
+
"data" => [1, 2, 2]
|
74
74
|
},
|
75
|
-
@store.coverage[
|
75
|
+
@store.coverage["./dog.rb"]
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_ttl_set
|
80
|
-
mock_file_hash(hash:
|
81
|
-
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace:
|
80
|
+
mock_file_hash(hash: "abcd")
|
81
|
+
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace: "coverband_test", ttl: 3600, relative_file_converter: MockRelativeFileConverter)
|
82
82
|
@store.save_report(
|
83
|
-
|
83
|
+
"app_path/dog.rb" => [0, 1, 2]
|
84
84
|
)
|
85
85
|
assert_operator(@redis.ttl("#{REDIS_STORAGE_FORMAT_VERSION}.coverband_test.runtime../dog.rb.abcd"), :>, 0)
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_no_ttl_set
|
89
|
-
mock_file_hash(hash:
|
90
|
-
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace:
|
89
|
+
mock_file_hash(hash: "abcd")
|
90
|
+
@store = Coverband::Adapters::HashRedisStore.new(@redis, redis_namespace: "coverband_test", ttl: nil, relative_file_converter: MockRelativeFileConverter)
|
91
91
|
@store.save_report(
|
92
|
-
|
92
|
+
"app_path/dog.rb" => [0, 1, 2]
|
93
93
|
)
|
94
94
|
assert_equal(-1, @redis.ttl("#{REDIS_STORAGE_FORMAT_VERSION}.coverband_test.runtime../dog.rb.abcd"))
|
95
95
|
end
|
@@ -98,98 +98,98 @@ class HashRedisStoreTest < Minitest::Test
|
|
98
98
|
current_time = mock_time
|
99
99
|
mock_file_hash
|
100
100
|
data = {
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
"app_path/dog.rb" => [0, nil, 1, 2],
|
102
|
+
"app_path/cat.rb" => [1, 2, 0, 1, 5],
|
103
|
+
"app_path/ferrit.rb" => [1, 5, nil, 2, nil]
|
104
104
|
}
|
105
105
|
@store.save_report(data)
|
106
|
-
|
106
|
+
@store.coverage
|
107
107
|
assert_equal(
|
108
108
|
{
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
}, @store.coverage[
|
109
|
+
"first_updated_at" => current_time.to_i,
|
110
|
+
"last_updated_at" => current_time.to_i,
|
111
|
+
"file_hash" => "abcd",
|
112
|
+
"data" => [0, nil, 1, 2]
|
113
|
+
}, @store.coverage["./dog.rb"]
|
114
114
|
)
|
115
|
-
assert_equal [1, 2, 0, 1, 5], @store.coverage[
|
116
|
-
assert_equal [1, 5, nil, 2, nil], @store.coverage[
|
115
|
+
assert_equal [1, 2, 0, 1, 5], @store.coverage["./cat.rb"]["data"]
|
116
|
+
assert_equal [1, 5, nil, 2, nil], @store.coverage["./ferrit.rb"]["data"]
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_file_hash_change
|
120
|
-
mock_file_hash(hash:
|
121
|
-
@store.save_report(
|
122
|
-
|
123
|
-
assert_equal [0, nil, 1, 2], @store.coverage[
|
120
|
+
mock_file_hash(hash: "abc")
|
121
|
+
@store.save_report("app_path/dog.rb" => [0, nil, 1, 2])
|
122
|
+
@store.coverage
|
123
|
+
assert_equal [0, nil, 1, 2], @store.coverage["./dog.rb"]["data"]
|
124
124
|
@store.instance_eval { @file_hash_cache = {} }
|
125
|
-
mock_file_hash(hash:
|
126
|
-
assert_nil @store.coverage[
|
125
|
+
mock_file_hash(hash: "123")
|
126
|
+
assert_nil @store.coverage["./dog.rb"]
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_type
|
130
130
|
mock_file_hash
|
131
131
|
@store.type = :eager_loading
|
132
132
|
data = {
|
133
|
-
|
133
|
+
"app_path/dog.rb" => [0, nil, 1, 2]
|
134
134
|
}
|
135
135
|
@store.save_report(data)
|
136
136
|
assert_equal 1, @store.coverage.length
|
137
|
-
assert_equal [0, nil, 1, 2], @store.coverage[
|
137
|
+
assert_equal [0, nil, 1, 2], @store.coverage["./dog.rb"]["data"]
|
138
138
|
# eager_loading doesn't set last_updated_at
|
139
|
-
assert_nil @store.coverage[
|
139
|
+
assert_nil @store.coverage["./dog.rb"]["last_updated_at"]
|
140
140
|
@store.type = Coverband::RUNTIME_TYPE
|
141
141
|
data = {
|
142
|
-
|
142
|
+
"app_path/cat.rb" => [1, 2, 0, 1, 5]
|
143
143
|
}
|
144
144
|
current_time = Time.now.to_i
|
145
145
|
@store.save_report(data)
|
146
146
|
assert_equal 1, @store.coverage.length
|
147
|
-
assert_equal [1, 2, 0, 1, 5], @store.coverage[
|
148
|
-
assert current_time <= @store.coverage[
|
147
|
+
assert_equal [1, 2, 0, 1, 5], @store.coverage["./cat.rb"]["data"]
|
148
|
+
assert current_time <= @store.coverage["./cat.rb"]["last_updated_at"]
|
149
149
|
end
|
150
150
|
|
151
151
|
def test_coverage_type
|
152
152
|
mock_file_hash
|
153
153
|
@store.type = :eager_loading
|
154
154
|
data = {
|
155
|
-
|
155
|
+
"app_path/dog.rb" => [0, nil, 1, 2]
|
156
156
|
}
|
157
157
|
@store.save_report(data)
|
158
158
|
@store.type = Coverband::RUNTIME_TYPE
|
159
|
-
assert_equal [0, nil, 1, 2], @store.coverage(:eager_loading)[
|
159
|
+
assert_equal [0, nil, 1, 2], @store.coverage(:eager_loading)["./dog.rb"]["data"]
|
160
160
|
end
|
161
161
|
|
162
162
|
def test_clear
|
163
163
|
mock_file_hash
|
164
164
|
@store.type = Coverband::EAGER_TYPE
|
165
165
|
data = {
|
166
|
-
|
166
|
+
"app_path/dog.rb" => [0, nil, 1, 2]
|
167
167
|
}
|
168
168
|
@store.save_report(data)
|
169
169
|
assert_equal 1, @store.coverage.length
|
170
170
|
@store.type = Coverband::RUNTIME_TYPE
|
171
171
|
data = {
|
172
|
-
|
172
|
+
"app_path/cat.rb" => [1, 2, 0, 1, 5]
|
173
173
|
}
|
174
174
|
@store.save_report(data)
|
175
175
|
assert_equal 1, @store.coverage.length
|
176
|
-
@redis.set(
|
176
|
+
@redis.set("random", "data")
|
177
177
|
@store.clear!
|
178
178
|
@store.type = Coverband::RUNTIME_TYPE
|
179
179
|
assert @store.coverage.empty?
|
180
180
|
@store.type = :eager_loading
|
181
181
|
assert @store.coverage.empty?
|
182
|
-
assert_equal
|
182
|
+
assert_equal "data", @redis.get("random")
|
183
183
|
end
|
184
184
|
|
185
185
|
def test_clear_file
|
186
186
|
mock_file_hash
|
187
187
|
@store.type = :eager_loading
|
188
|
-
@store.save_report(
|
188
|
+
@store.save_report("app_path/dog.rb" => [0, 1, 1])
|
189
189
|
@store.type = Coverband::RUNTIME_TYPE
|
190
|
-
@store.save_report(
|
191
|
-
assert_equal [1, 1, 2], @store.get_coverage_report[:merged][
|
192
|
-
@store.clear_file!(
|
193
|
-
assert_nil @store.get_coverage_report[:merged][
|
190
|
+
@store.save_report("app_path/dog.rb" => [1, 0, 1])
|
191
|
+
assert_equal [1, 1, 2], @store.get_coverage_report[:merged]["./dog.rb"]["data"]
|
192
|
+
@store.clear_file!("app_path/dog.rb")
|
193
|
+
assert_nil @store.get_coverage_report[:merged]["./dog.rb"]
|
194
194
|
end
|
195
195
|
end
|
@@ -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
|
|
5
|
-
unless ENV[
|
5
|
+
unless ENV["COVERBAND_HASH_REDIS_STORE"]
|
6
6
|
class RedisTest < Minitest::Test
|
7
7
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
|
8
8
|
|
@@ -18,7 +18,7 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
18
18
|
@store.save_report(expected)
|
19
19
|
assert_equal expected.keys, @store.coverage.keys
|
20
20
|
@store.coverage.each_pair do |key, data|
|
21
|
-
assert_equal expected[key], data[
|
21
|
+
assert_equal expected[key], data["data"]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -28,20 +28,20 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
28
28
|
@store.save_report(basic_coverage.dup)
|
29
29
|
assert_equal expected.keys, @store.coverage.keys
|
30
30
|
@store.coverage.each_pair do |key, data|
|
31
|
-
assert_equal expected[key], data[
|
31
|
+
assert_equal expected[key], data["data"]
|
32
32
|
end
|
33
33
|
current_time = Time.now.to_i
|
34
34
|
@store.save_report(basic_coverage.dup)
|
35
|
-
assert_equal [0, 2, 4], @store.coverage[
|
36
|
-
assert current_time <= @store.coverage[
|
35
|
+
assert_equal [0, 2, 4], @store.coverage["app_path/dog.rb"]["data"]
|
36
|
+
assert current_time <= @store.coverage["app_path/dog.rb"]["last_updated_at"]
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_file_hash_change
|
40
|
-
mock_file_hash(hash:
|
41
|
-
@store.save_report(
|
42
|
-
assert_equal [0, nil, 1, 2], @store.coverage[
|
43
|
-
mock_file_hash(hash:
|
44
|
-
assert_nil @store.coverage[
|
40
|
+
mock_file_hash(hash: "abc")
|
41
|
+
@store.save_report("app_path/dog.rb" => [0, nil, 1, 2])
|
42
|
+
assert_equal [0, nil, 1, 2], @store.coverage["app_path/dog.rb"]["data"]
|
43
|
+
mock_file_hash(hash: "123")
|
44
|
+
assert_nil @store.coverage["app_path/dog.rb"]
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_store_coverage_by_type
|
@@ -51,7 +51,7 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
51
51
|
@store.save_report(expected)
|
52
52
|
assert_equal expected.keys, @store.coverage.keys
|
53
53
|
@store.coverage.each_pair do |key, data|
|
54
|
-
assert_equal expected[key], data[
|
54
|
+
assert_equal expected[key], data["data"]
|
55
55
|
end
|
56
56
|
@store.type = Coverband::RUNTIME_TYPE
|
57
57
|
assert_equal [], @store.coverage.keys
|
@@ -61,14 +61,14 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
61
61
|
mock_file_hash
|
62
62
|
assert_equal Coverband::RUNTIME_TYPE, @store.type
|
63
63
|
@store.type = :eager_loading
|
64
|
-
@store.save_report(
|
64
|
+
@store.save_report("app_path/dog.rb" => [0, 1, 1])
|
65
65
|
# eager_loading doesn't set last_updated_at
|
66
|
-
assert_nil @store.coverage[
|
66
|
+
assert_nil @store.coverage["app_path/dog.rb"]["last_updated_at"]
|
67
67
|
@store.type = Coverband::RUNTIME_TYPE
|
68
68
|
current_time = Time.now.to_i
|
69
|
-
@store.save_report(
|
70
|
-
assert_equal [1, 1, 2], @store.get_coverage_report[:merged][
|
71
|
-
assert current_time <= @store.coverage[
|
69
|
+
@store.save_report("app_path/dog.rb" => [1, 0, 1])
|
70
|
+
assert_equal [1, 1, 2], @store.get_coverage_report[:merged]["app_path/dog.rb"]["data"]
|
71
|
+
assert current_time <= @store.coverage["app_path/dog.rb"]["last_updated_at"]
|
72
72
|
assert_equal Coverband::RUNTIME_TYPE, @store.type
|
73
73
|
end
|
74
74
|
|
@@ -76,7 +76,7 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
76
76
|
mock_file_hash
|
77
77
|
expected = basic_coverage
|
78
78
|
@store.save_report(expected)
|
79
|
-
assert_equal example_line, @store.coverage[
|
79
|
+
assert_equal example_line, @store.coverage["app_path/dog.rb"]["data"]
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_coverage_with_simulate_oneshot_lines_coverage
|
@@ -84,11 +84,11 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
84
84
|
mock_file_hash
|
85
85
|
expected = basic_coverage
|
86
86
|
@store.save_report(expected)
|
87
|
-
assert_equal example_line, @store.get_coverage_report[:runtime][
|
87
|
+
assert_equal example_line, @store.get_coverage_report[:runtime]["app_path/dog.rb"]["data"]
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_coverage_when_null
|
91
|
-
assert_nil @store.coverage[
|
91
|
+
assert_nil @store.coverage["app_path/dog.rb"]
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_clear
|
@@ -99,18 +99,18 @@ unless ENV['COVERBAND_HASH_REDIS_STORE']
|
|
99
99
|
def test_clear_file
|
100
100
|
mock_file_hash
|
101
101
|
@store.type = :eager_loading
|
102
|
-
@store.save_report(
|
102
|
+
@store.save_report("app_path/dog.rb" => [0, 1, 1])
|
103
103
|
@store.type = Coverband::RUNTIME_TYPE
|
104
|
-
@store.save_report(
|
105
|
-
assert_equal [1, 1, 2], @store.get_coverage_report[:merged][
|
106
|
-
@store.clear_file!(
|
107
|
-
assert_nil @store.get_coverage_report[:merged][
|
104
|
+
@store.save_report("app_path/dog.rb" => [1, 0, 1])
|
105
|
+
assert_equal [1, 1, 2], @store.get_coverage_report[:merged]["app_path/dog.rb"]["data"]
|
106
|
+
@store.clear_file!("app_path/dog.rb")
|
107
|
+
assert_nil @store.get_coverage_report[:merged]["app_path/dog.rb"]
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_size
|
111
111
|
mock_file_hash
|
112
112
|
@store.type = :eager_loading
|
113
|
-
@store.save_report(
|
113
|
+
@store.save_report("app_path/dog.rb" => [0, 1, 1])
|
114
114
|
assert @store.size > 1
|
115
115
|
end
|
116
116
|
|