simplecov 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -2
- data/.travis.yml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -2
- data/MIT-LICENSE +1 -1
- data/README.md +51 -5
- data/doc/editor-integration.md +6 -1
- data/features/config_tracked_files.feature +1 -1
- data/features/config_tracked_files_relevant_lines.feature +31 -0
- data/features/step_definitions/transformers.rb +1 -1
- data/features/support/aruba_freedom_patch.rb +53 -0
- data/features/support/env.rb +5 -5
- data/lib/simplecov.rb +16 -10
- data/lib/simplecov/configuration.rb +5 -9
- data/lib/simplecov/defaults.rb +4 -4
- data/lib/simplecov/file_list.rb +5 -5
- data/lib/simplecov/filter.rb +39 -4
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/lines_classifier.rb +32 -0
- data/lib/simplecov/result_merger.rb +42 -13
- data/lib/simplecov/source_file.rb +6 -1
- data/lib/simplecov/version.rb +1 -23
- data/spec/filters_spec.rb +74 -0
- data/spec/lines_classifier_spec.rb +103 -0
- data/spec/result_merger_spec.rb +89 -6
- data/spec/simplecov_spec.rb +109 -0
- data/spec/source_file_spec.rb +4 -0
- metadata +20 -15
data/spec/result_merger_spec.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
require "helper"
|
2
|
+
require "tempfile"
|
3
|
+
require "timeout"
|
2
4
|
|
3
5
|
if SimpleCov.usable?
|
4
6
|
describe SimpleCov::ResultMerger do
|
7
|
+
before do
|
8
|
+
SimpleCov::ResultMerger.clear_resultset
|
9
|
+
File.delete(SimpleCov::ResultMerger.resultset_path) if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
10
|
+
end
|
11
|
+
|
5
12
|
describe "with two faked coverage resultsets" do
|
6
13
|
before do
|
7
|
-
SimpleCov.use_merging true
|
8
14
|
@resultset1 = {
|
9
15
|
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
10
16
|
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
@@ -56,7 +62,7 @@ if SimpleCov.usable?
|
|
56
62
|
end
|
57
63
|
|
58
64
|
it "returns a hash containing keys ['result1' and 'result2'] for resultset" do
|
59
|
-
expect(SimpleCov::ResultMerger.resultset.keys.sort).to eq %w
|
65
|
+
expect(SimpleCov::ResultMerger.resultset.keys.sort).to eq %w[result1 result2]
|
60
66
|
end
|
61
67
|
|
62
68
|
it "returns proper values for merged_result" do
|
@@ -73,15 +79,92 @@ if SimpleCov.usable?
|
|
73
79
|
expect(SimpleCov::ResultMerger.results.length).to eq(1)
|
74
80
|
end
|
75
81
|
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe ".store_result" do
|
87
|
+
it "refreshes the resultset" do
|
88
|
+
set = SimpleCov::ResultMerger.resultset
|
89
|
+
SimpleCov::ResultMerger.store_result({})
|
90
|
+
new_set = SimpleCov::ResultMerger.resultset
|
91
|
+
expect(new_set).not_to be(set)
|
92
|
+
end
|
76
93
|
|
77
|
-
|
78
|
-
|
94
|
+
it "persists to disk" do
|
95
|
+
SimpleCov::ResultMerger.store_result("a" => [1])
|
96
|
+
SimpleCov::ResultMerger.clear_resultset
|
97
|
+
new_set = SimpleCov::ResultMerger.resultset
|
98
|
+
expect(new_set).to eq("a" => [1])
|
99
|
+
end
|
100
|
+
|
101
|
+
it "synchronizes writes" do
|
102
|
+
expect(SimpleCov::ResultMerger).to receive(:synchronize_resultset)
|
103
|
+
SimpleCov::ResultMerger.store_result({})
|
104
|
+
end
|
105
|
+
end
|
79
106
|
|
80
|
-
|
81
|
-
|
107
|
+
describe ".resultset" do
|
108
|
+
it "caches" do
|
109
|
+
set = SimpleCov::ResultMerger.resultset
|
110
|
+
new_set = SimpleCov::ResultMerger.resultset
|
111
|
+
expect(new_set).to be(set)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "synchronizes reads" do
|
115
|
+
expect(SimpleCov::ResultMerger).to receive(:synchronize_resultset)
|
116
|
+
SimpleCov::ResultMerger.resultset
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe ".synchronize_resultset" do
|
121
|
+
it "is reentrant (i.e. doesn't block its own process)" do
|
122
|
+
# without @resultset_locked, this spec would fail and
|
123
|
+
# `.store_result` wouldn't work
|
124
|
+
expect do
|
125
|
+
Timeout.timeout(1) do
|
126
|
+
SimpleCov::ResultMerger.synchronize_resultset do
|
127
|
+
SimpleCov::ResultMerger.synchronize_resultset do
|
128
|
+
end
|
82
129
|
end
|
83
130
|
end
|
131
|
+
end.not_to raise_error
|
132
|
+
end
|
133
|
+
|
134
|
+
it "blocks other processes" do
|
135
|
+
file = Tempfile.new("foo")
|
136
|
+
|
137
|
+
other_process = open("|ruby -e " + Shellwords.escape(<<-CODE) + " 2>/dev/null")
|
138
|
+
require "simplecov"
|
139
|
+
SimpleCov.coverage_dir(#{SimpleCov.coverage_dir.inspect})
|
140
|
+
|
141
|
+
# ensure the parent process has enough time to get a
|
142
|
+
# lock before we do
|
143
|
+
sleep 0.5
|
144
|
+
|
145
|
+
$stdout.sync = true
|
146
|
+
puts "running" # see `sleep`s in parent process
|
147
|
+
|
148
|
+
SimpleCov::ResultMerger.synchronize_resultset do
|
149
|
+
File.open(#{file.path.inspect}, "a") { |f| f.write("process 2\n") }
|
150
|
+
end
|
151
|
+
CODE
|
152
|
+
|
153
|
+
SimpleCov::ResultMerger.synchronize_resultset do
|
154
|
+
# wait until the child process is going, and then wait some more
|
155
|
+
# so we can be sure it blocks on the lock we already have.
|
156
|
+
sleep 0.1 until other_process.gets == "running\n"
|
157
|
+
sleep 1
|
158
|
+
|
159
|
+
# despite the sleeps, this will be written first since we got
|
160
|
+
# the first lock
|
161
|
+
File.open(file.path, "a") { |f| f.write("process 1\n") }
|
84
162
|
end
|
163
|
+
|
164
|
+
# wait for it to finish
|
165
|
+
other_process.gets
|
166
|
+
|
167
|
+
expect(file.read).to eq("process 1\nprocess 2\n")
|
85
168
|
end
|
86
169
|
end
|
87
170
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
if SimpleCov.usable?
|
4
|
+
describe SimpleCov do
|
5
|
+
describe ".result" do
|
6
|
+
before do
|
7
|
+
SimpleCov.clear_result
|
8
|
+
allow(Coverage).to receive(:result).once.and_return({})
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with merging disabled" do
|
12
|
+
before do
|
13
|
+
allow(SimpleCov).to receive(:use_merging).once.and_return(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when not running" do
|
17
|
+
before do
|
18
|
+
allow(SimpleCov).to receive(:running).and_return(false)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns nil" do
|
22
|
+
expect(SimpleCov.result).to be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when running" do
|
27
|
+
before do
|
28
|
+
allow(SimpleCov).to receive(:running).and_return(true, false)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "uses the result from Coverage" do
|
32
|
+
expect(Coverage).to receive(:result).once.and_return(__FILE__ => [0, 1])
|
33
|
+
expect(SimpleCov.result.filenames).to eq [__FILE__]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "adds not-loaded-files" do
|
37
|
+
expect(SimpleCov).to receive(:add_not_loaded_files).once.and_return({})
|
38
|
+
SimpleCov.result
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't store the current coverage" do
|
42
|
+
expect(SimpleCov::ResultMerger).not_to receive(:store_result)
|
43
|
+
SimpleCov.result
|
44
|
+
end
|
45
|
+
|
46
|
+
it "doesn't merge the result" do
|
47
|
+
expect(SimpleCov::ResultMerger).not_to receive(:merged_result)
|
48
|
+
SimpleCov.result
|
49
|
+
end
|
50
|
+
|
51
|
+
it "caches its result" do
|
52
|
+
result = SimpleCov.result
|
53
|
+
expect(SimpleCov.result).to be(result)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with merging enabled" do
|
59
|
+
let(:the_merged_result) { double }
|
60
|
+
|
61
|
+
before do
|
62
|
+
allow(SimpleCov).to receive(:use_merging).once.and_return(true)
|
63
|
+
allow(SimpleCov::ResultMerger).to receive(:store_result).once
|
64
|
+
allow(SimpleCov::ResultMerger).to receive(:merged_result).once.and_return(the_merged_result)
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when not running" do
|
68
|
+
before do
|
69
|
+
allow(SimpleCov).to receive(:running).and_return(false)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "merges the result" do
|
73
|
+
expect(SimpleCov.result).to be(the_merged_result)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when running" do
|
78
|
+
before do
|
79
|
+
allow(SimpleCov).to receive(:running).and_return(true, false)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "uses the result from Coverage" do
|
83
|
+
expect(Coverage).to receive(:result).once.and_return({})
|
84
|
+
SimpleCov.result
|
85
|
+
end
|
86
|
+
|
87
|
+
it "adds not-loaded-files" do
|
88
|
+
expect(SimpleCov).to receive(:add_not_loaded_files).once.and_return({})
|
89
|
+
SimpleCov.result
|
90
|
+
end
|
91
|
+
|
92
|
+
it "stores the current coverage" do
|
93
|
+
expect(SimpleCov::ResultMerger).to receive(:store_result).once
|
94
|
+
SimpleCov.result
|
95
|
+
end
|
96
|
+
|
97
|
+
it "merges the result" do
|
98
|
+
expect(SimpleCov.result).to be(the_merged_result)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "caches its result" do
|
102
|
+
result = SimpleCov.result
|
103
|
+
expect(SimpleCov.result).to be(result)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/spec/source_file_spec.rb
CHANGED
@@ -16,6 +16,10 @@ if SimpleCov.usable?
|
|
16
16
|
expect(subject.src).to eq(subject.source)
|
17
17
|
end
|
18
18
|
|
19
|
+
it "has a project filename which removes the project directory" do
|
20
|
+
expect(subject.project_filename).to eq("/spec/fixtures/sample.rb")
|
21
|
+
end
|
22
|
+
|
19
23
|
it "has source_lines equal to lines" do
|
20
24
|
expect(subject.lines).to eq(subject.source_lines)
|
21
25
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Olszowka
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
@@ -20,8 +19,9 @@ dependencies:
|
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: '3'
|
23
|
-
|
22
|
+
name: json
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -31,42 +31,42 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: simplecov-html
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
36
|
- - "~>"
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: 0.10.0
|
40
|
-
|
39
|
+
name: simplecov-html
|
41
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.10.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name: docile
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
50
|
- - "~>"
|
52
51
|
- !ruby/object:Gem::Version
|
53
52
|
version: 1.1.0
|
54
|
-
|
53
|
+
name: docile
|
55
54
|
prerelease: false
|
55
|
+
type: :runtime
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.1.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: bundler
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
64
63
|
requirements:
|
65
64
|
- - "~>"
|
66
65
|
- !ruby/object:Gem::Version
|
67
66
|
version: '1.9'
|
68
|
-
|
67
|
+
name: bundler
|
69
68
|
prerelease: false
|
69
|
+
type: :development
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- features/config_project_name.feature
|
107
107
|
- features/config_styles.feature
|
108
108
|
- features/config_tracked_files.feature
|
109
|
+
- features/config_tracked_files_relevant_lines.feature
|
109
110
|
- features/cucumber_basic.feature
|
110
111
|
- features/maximum_coverage_drop.feature
|
111
112
|
- features/merging_test_unit_and_rspec.feature
|
@@ -122,6 +123,7 @@ files:
|
|
122
123
|
- features/step_definitions/simplecov_steps.rb
|
123
124
|
- features/step_definitions/transformers.rb
|
124
125
|
- features/step_definitions/web_steps.rb
|
126
|
+
- features/support/aruba_freedom_patch.rb
|
125
127
|
- features/support/env.rb
|
126
128
|
- features/test_unit_basic.feature
|
127
129
|
- features/test_unit_groups_and_filters_basic.feature
|
@@ -141,6 +143,7 @@ files:
|
|
141
143
|
- lib/simplecov/formatter/simple_formatter.rb
|
142
144
|
- lib/simplecov/jruby_fix.rb
|
143
145
|
- lib/simplecov/last_run.rb
|
146
|
+
- lib/simplecov/lines_classifier.rb
|
144
147
|
- lib/simplecov/load_global_config.rb
|
145
148
|
- lib/simplecov/no_defaults.rb
|
146
149
|
- lib/simplecov/profiles.rb
|
@@ -196,11 +199,13 @@ files:
|
|
196
199
|
- spec/fixtures/utf-8.rb
|
197
200
|
- spec/helper.rb
|
198
201
|
- spec/last_run_spec.rb
|
202
|
+
- spec/lines_classifier_spec.rb
|
199
203
|
- spec/multi_formatter_spec.rb
|
200
204
|
- spec/raw_coverage_spec.rb
|
201
205
|
- spec/result_merger_spec.rb
|
202
206
|
- spec/result_spec.rb
|
203
207
|
- spec/return_codes_spec.rb
|
208
|
+
- spec/simplecov_spec.rb
|
204
209
|
- spec/source_file_line_spec.rb
|
205
210
|
- spec/source_file_spec.rb
|
206
211
|
- spec/support/fail_rspec_on_ruby_warning.rb
|
@@ -208,7 +213,7 @@ homepage: http://github.com/colszowka/simplecov
|
|
208
213
|
licenses:
|
209
214
|
- MIT
|
210
215
|
metadata: {}
|
211
|
-
post_install_message:
|
216
|
+
post_install_message:
|
212
217
|
rdoc_options: []
|
213
218
|
require_paths:
|
214
219
|
- lib
|
@@ -223,9 +228,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
228
|
- !ruby/object:Gem::Version
|
224
229
|
version: '0'
|
225
230
|
requirements: []
|
226
|
-
rubyforge_project:
|
227
|
-
rubygems_version: 2.6.
|
228
|
-
signing_key:
|
231
|
+
rubyforge_project:
|
232
|
+
rubygems_version: 2.6.11
|
233
|
+
signing_key:
|
229
234
|
specification_version: 4
|
230
235
|
summary: Code coverage for Ruby 1.9+ with a powerful configuration library and automatic
|
231
236
|
merging of coverage across test suites
|