simplecov 0.6.4 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +378 -12
- data/CONTRIBUTING.md +51 -0
- data/ISSUE_TEMPLATE.md +23 -0
- data/LICENSE +1 -1
- data/README.md +456 -252
- data/doc/alternate-formatters.md +56 -0
- data/doc/commercial-services.md +20 -0
- data/doc/editor-integration.md +18 -0
- data/lib/simplecov.rb +223 -44
- data/lib/simplecov/command_guesser.rb +47 -35
- data/lib/simplecov/configuration.rb +281 -191
- data/lib/simplecov/defaults.rb +38 -43
- data/lib/simplecov/exit_codes.rb +10 -0
- data/lib/simplecov/file_list.rb +51 -34
- data/lib/simplecov/filter.rb +50 -3
- data/lib/simplecov/formatter.rb +4 -1
- data/lib/simplecov/formatter/multi_formatter.rb +34 -0
- data/lib/simplecov/formatter/simple_formatter.rb +18 -12
- data/lib/simplecov/jruby_fix.rb +44 -0
- data/lib/simplecov/last_run.rb +26 -0
- data/lib/simplecov/lines_classifier.rb +48 -0
- data/lib/simplecov/load_global_config.rb +8 -0
- data/lib/simplecov/no_defaults.rb +4 -0
- data/lib/simplecov/profiles.rb +33 -0
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/railtie.rb +3 -1
- data/lib/simplecov/railties/tasks.rake +9 -7
- data/lib/simplecov/raw_coverage.rb +41 -0
- data/lib/simplecov/result.rb +17 -55
- data/lib/simplecov/result_merger.rb +100 -67
- data/lib/simplecov/source_file.rb +82 -67
- data/lib/simplecov/version.rb +4 -2
- metadata +153 -222
- data/.gitignore +0 -31
- data/.travis.yml +0 -15
- data/Appraisals +0 -8
- data/Gemfile +0 -5
- data/Rakefile +0 -19
- data/cucumber.yml +0 -13
- data/features/config_adapters.feature +0 -44
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -33
- data/features/config_coverage_dir.feature +0 -20
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -93
- data/features/cucumber_basic.feature +0 -29
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/rspec_basic.feature +0 -31
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -35
- data/features/rspec_groups_using_filter_class.feature +0 -40
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -45
- data/features/step_definitions/simplecov_steps.rb +0 -66
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/env.rb +0 -26
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/gemfiles/multi_json-legacy.gemfile +0 -7
- data/gemfiles/multi_json-legacy.gemfile.lock +0 -85
- data/gemfiles/multi_json-new.gemfile +0 -7
- data/gemfiles/multi_json-new.gemfile.lock +0 -85
- data/lib/simplecov/adapters.rb +0 -29
- data/lib/simplecov/merge_helpers.rb +0 -39
- data/simplecov.gemspec +0 -29
- data/test/faked_project/Gemfile +0 -6
- data/test/faked_project/Rakefile +0 -8
- data/test/faked_project/cucumber.yml +0 -13
- data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
- data/test/faked_project/features/support/env.rb +0 -12
- data/test/faked_project/features/test_stuff.feature +0 -6
- data/test/faked_project/lib/faked_project.rb +0 -11
- data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/test/faked_project/lib/faked_project/some_class.rb +0 -29
- data/test/faked_project/spec/faked_spec.rb +0 -11
- data/test/faked_project/spec/meta_magic_spec.rb +0 -10
- data/test/faked_project/spec/some_class_spec.rb +0 -10
- data/test/faked_project/spec/spec_helper.rb +0 -15
- data/test/faked_project/test/faked_test.rb +0 -11
- data/test/faked_project/test/meta_magic_test.rb +0 -13
- data/test/faked_project/test/some_class_test.rb +0 -15
- data/test/faked_project/test/test_helper.rb +0 -16
- data/test/fixtures/app/controllers/sample_controller.rb +0 -10
- data/test/fixtures/app/models/user.rb +0 -10
- data/test/fixtures/deleted_source_sample.rb +0 -15
- data/test/fixtures/frameworks/rspec_bad.rb +0 -9
- data/test/fixtures/frameworks/rspec_good.rb +0 -9
- data/test/fixtures/frameworks/testunit_bad.rb +0 -9
- data/test/fixtures/frameworks/testunit_good.rb +0 -9
- data/test/fixtures/iso-8859.rb +0 -3
- data/test/fixtures/resultset1.rb +0 -4
- data/test/fixtures/resultset2.rb +0 -5
- data/test/fixtures/sample.rb +0 -16
- data/test/fixtures/utf-8.rb +0 -3
- data/test/helper.rb +0 -35
- data/test/shoulda_macros.rb +0 -29
- data/test/test_1_8_fallbacks.rb +0 -33
- data/test/test_command_guesser.rb +0 -21
- data/test/test_deleted_source.rb +0 -16
- data/test/test_file_list.rb +0 -24
- data/test/test_filters.rb +0 -80
- data/test/test_merge_helpers.rb +0 -107
- data/test/test_result.rb +0 -147
- data/test/test_return_codes.rb +0 -39
- data/test/test_source_file.rb +0 -95
- data/test/test_source_file_line.rb +0 -110
@@ -0,0 +1,56 @@
|
|
1
|
+
## Alternate coverage report formatters
|
2
|
+
|
3
|
+
The community around simplecov provides a whole bunch of alternate formatters beyond the official
|
4
|
+
[simplecov-html](https://github.com/colszowka/simplecov-html) gem.
|
5
|
+
|
6
|
+
If you have built or found one that is missing here, please send a Pull Request for this document!
|
7
|
+
|
8
|
+
#### [simplecov-badge](https://github.com/matthew342/simplecov-badge)
|
9
|
+
*by Matt Hale*
|
10
|
+
|
11
|
+
A formatter that generates a coverage badge for use in your project's readme using ImageMagick.
|
12
|
+
|
13
|
+
#### [simplecov-small-badge](https://github.com/marcgrimme/simplecov-small-badge)
|
14
|
+
*by Marc Grimme*
|
15
|
+
|
16
|
+
A formatter that generates a small coverage badge for use in your project's readme using the SVG.
|
17
|
+
|
18
|
+
#### [simplecov-cobertura](https://github.com/dashingrocket/simplecov-cobertura)
|
19
|
+
*by Jesse Bowes*
|
20
|
+
|
21
|
+
A formatter that generates Cobertura XML.
|
22
|
+
|
23
|
+
#### [simplecov-csv](https://github.com/fguillen/simplecov-csv)
|
24
|
+
*by Fernando Guillen*
|
25
|
+
|
26
|
+
CSV formatter for SimpleCov
|
27
|
+
|
28
|
+
#### [simplecov-erb](https://github.com/kpaulisse/simplecov-erb)
|
29
|
+
*by [Kevin Paulisse](https://github.com/kpaulisse)*
|
30
|
+
|
31
|
+
Flexible formatter that generates the output from an ERB template.
|
32
|
+
|
33
|
+
#### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
|
34
|
+
*by Vicent Llongo*
|
35
|
+
|
36
|
+
JSON formatter for SimpleCov
|
37
|
+
|
38
|
+
#### [simplecov-lcov](https://github.com/fortissimo1997/simplecov-lcov)
|
39
|
+
*by fortissimo1997*
|
40
|
+
|
41
|
+
lcov formatter for SimpleCov
|
42
|
+
|
43
|
+
#### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
|
44
|
+
*by Fernando Guillen*
|
45
|
+
|
46
|
+
"The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov."
|
47
|
+
|
48
|
+
#### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
|
49
|
+
*by [Michael Grosser](http://grosser.it)*
|
50
|
+
|
51
|
+
A formatter that prints the coverage of the file under test when you run a single test file.
|
52
|
+
|
53
|
+
#### [simplecov-t_wada](https://github.com/ysksn/simplecov-t_wada)
|
54
|
+
*by [Yosuke Kabuto](https://github.com/ysksn)*
|
55
|
+
|
56
|
+
t_wada AA formatter for SimpleCov
|
@@ -0,0 +1,20 @@
|
|
1
|
+
## Commercial Services with SimpleCov integration
|
2
|
+
|
3
|
+
There is a bunch of services that offer integration with your existing CI pipeline and SimpleCov coverage
|
4
|
+
reports. Please note these are not associated with the SimpleCov project itself, so please report problems with
|
5
|
+
these integrations with their respective owners.
|
6
|
+
|
7
|
+
#### [codeclimate](https://github.com/codeclimate/ruby-test-reporter)
|
8
|
+
*by [Code Climate](https://codeclimate.com/)*
|
9
|
+
|
10
|
+
Upload coverage reports to [codeclimate.com](https://codeclimate.com/), a hosted software quality analysis and that also includes coverage reporting.
|
11
|
+
|
12
|
+
#### [codecov](https://github.com/codecov/codecov-ruby)
|
13
|
+
*by [Codecov](https://codecov.io/)*
|
14
|
+
|
15
|
+
Upload coverage reports to [codecov.io](https://codecov.io/), a hosted coverage reporting solution.
|
16
|
+
|
17
|
+
#### [coveralls](https://github.com/lemurheavy/coveralls-ruby)
|
18
|
+
*by [Coveralls](https://coveralls.io/)*
|
19
|
+
|
20
|
+
Upload coverage reports to [coveralls.io](https://coveralls.io/), a hosted coverage reporting solution.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
## Editor integration
|
2
|
+
|
3
|
+
Some editors have a graphical integration for the simplecov gem.
|
4
|
+
|
5
|
+
#### [Atom Editor: coverage](https://atom.io/packages/coverage)
|
6
|
+
*by Philip Giuliani*
|
7
|
+
|
8
|
+
Adds an overview of your current test coverage to Atom.
|
9
|
+
|
10
|
+
#### [Sublime Editor: SimpleCov](https://packagecontrol.io/packages/SimpleCov)
|
11
|
+
*by sentience*
|
12
|
+
|
13
|
+
Adds in editor live coverage highlighting, status bar coverage information, and summary coverage information.
|
14
|
+
|
15
|
+
#### [cadre](https://github.com/nyarly/cadre)
|
16
|
+
*by Judson Lester*
|
17
|
+
|
18
|
+
Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
|
data/lib/simplecov.rb
CHANGED
@@ -1,19 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
|
1
5
|
#
|
2
6
|
# Code coverage for ruby 1.9. Please check out README for a full introduction.
|
3
7
|
#
|
4
|
-
|
5
|
-
|
6
|
-
class CoverageDataError < StandardError; end;
|
8
|
+
# Coverage may be inaccurate under JRUBY.
|
9
|
+
if defined?(JRUBY_VERSION) && defined?(JRuby)
|
7
10
|
|
11
|
+
# @see https://github.com/jruby/jruby/issues/1196
|
12
|
+
# @see https://github.com/metricfu/metric_fu/pull/226
|
13
|
+
# @see https://github.com/colszowka/simplecov/issues/420
|
14
|
+
# @see https://github.com/colszowka/simplecov/issues/86
|
15
|
+
# @see https://jira.codehaus.org/browse/JRUBY-6106
|
16
|
+
|
17
|
+
unless org.jruby.RubyInstanceConfig.FULL_TRACE_ENABLED
|
18
|
+
warn 'Coverage may be inaccurate; set the "--debug" command line option,' \
|
19
|
+
' or do JRUBY_OPTS="--debug"' \
|
20
|
+
' or set the "debug.fullTrace=true" option in your .jrubyrc'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
module SimpleCov
|
8
24
|
class << self
|
9
|
-
attr_accessor :running
|
25
|
+
attr_accessor :running
|
26
|
+
attr_accessor :pid
|
27
|
+
attr_reader :exit_exception
|
10
28
|
|
11
29
|
#
|
12
30
|
# Sets up SimpleCov to run against your project.
|
13
|
-
# You can optionally specify
|
31
|
+
# You can optionally specify a profile to use as well as configuration with a block:
|
14
32
|
# SimpleCov.start
|
15
33
|
# OR
|
16
|
-
# SimpleCov.start 'rails' # using rails
|
34
|
+
# SimpleCov.start 'rails' # using rails profile
|
17
35
|
# OR
|
18
36
|
# SimpleCov.start do
|
19
37
|
# add_filter 'test'
|
@@ -25,15 +43,36 @@ module SimpleCov
|
|
25
43
|
#
|
26
44
|
# Please check out the RDoc for SimpleCov::Configuration to find about available config options
|
27
45
|
#
|
28
|
-
def start(
|
29
|
-
|
46
|
+
def start(profile = nil, &block)
|
47
|
+
if SimpleCov.usable?
|
48
|
+
load_profile(profile) if profile
|
49
|
+
configure(&block) if block_given?
|
50
|
+
@result = nil
|
51
|
+
self.running = true
|
52
|
+
self.pid = Process.pid
|
53
|
+
Coverage.start
|
54
|
+
else
|
55
|
+
warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
|
56
|
+
warn "Starting with SimpleCov 1.0.0, even no-op compatibility with Ruby <= 1.8 will be entirely dropped."
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Finds files that were to be tracked but were not loaded and initializes
|
63
|
+
# the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).
|
64
|
+
#
|
65
|
+
def add_not_loaded_files(result)
|
66
|
+
if tracked_files
|
67
|
+
result = result.dup
|
68
|
+
Dir[tracked_files].each do |file|
|
69
|
+
absolute = File.expand_path(file)
|
30
70
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
self.running = true
|
71
|
+
result[absolute] ||= LinesClassifier.new.classify(File.foreach(absolute))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
result
|
37
76
|
end
|
38
77
|
|
39
78
|
#
|
@@ -41,26 +80,41 @@ module SimpleCov
|
|
41
80
|
# from cache using SimpleCov::ResultMerger if use_merging is activated (default)
|
42
81
|
#
|
43
82
|
def result
|
44
|
-
@result
|
83
|
+
return @result if result?
|
84
|
+
|
85
|
+
# Collect our coverage result
|
86
|
+
if running
|
87
|
+
@result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
|
88
|
+
end
|
89
|
+
|
45
90
|
# If we're using merging of results, store the current result
|
46
|
-
# first, then merge the results and return those
|
91
|
+
# first (if there is one), then merge the results and return those
|
47
92
|
if use_merging
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return @result if defined? @result
|
93
|
+
wait_for_other_processes
|
94
|
+
SimpleCov::ResultMerger.store_result(@result) if result?
|
95
|
+
@result = SimpleCov::ResultMerger.merged_result
|
52
96
|
end
|
97
|
+
|
98
|
+
@result
|
53
99
|
ensure
|
54
100
|
self.running = false
|
55
101
|
end
|
56
102
|
|
103
|
+
#
|
104
|
+
# Returns nil if the result has not been computed
|
105
|
+
# Otherwise, returns the result
|
106
|
+
#
|
107
|
+
def result?
|
108
|
+
defined?(@result) && @result
|
109
|
+
end
|
110
|
+
|
57
111
|
#
|
58
112
|
# Applies the configured filters to the given array of SimpleCov::SourceFile items
|
59
113
|
#
|
60
114
|
def filtered(files)
|
61
115
|
result = files.clone
|
62
116
|
filters.each do |filter|
|
63
|
-
result = result.reject {|source_file| filter.matches?(source_file) }
|
117
|
+
result = result.reject { |source_file| filter.matches?(source_file) }
|
64
118
|
end
|
65
119
|
SimpleCov::FileList.new result
|
66
120
|
end
|
@@ -72,52 +126,177 @@ module SimpleCov
|
|
72
126
|
grouped = {}
|
73
127
|
grouped_files = []
|
74
128
|
groups.each do |name, filter|
|
75
|
-
grouped[name] = SimpleCov::FileList.new(files.select {|source_file| filter.matches?(source_file)})
|
129
|
+
grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
|
76
130
|
grouped_files += grouped[name]
|
77
131
|
end
|
78
|
-
if groups.
|
132
|
+
if !groups.empty? && !(other_files = files.reject { |source_file| grouped_files.include?(source_file) }).empty?
|
79
133
|
grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
|
80
134
|
end
|
81
135
|
grouped
|
82
136
|
end
|
83
137
|
|
84
138
|
#
|
85
|
-
# Applies the
|
139
|
+
# Applies the profile of given name on SimpleCov configuration
|
86
140
|
#
|
141
|
+
def load_profile(name)
|
142
|
+
profiles.load(name)
|
143
|
+
end
|
144
|
+
|
87
145
|
def load_adapter(name)
|
88
|
-
|
146
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #load_adapter is deprecated. Use #load_profile instead."
|
147
|
+
load_profile(name)
|
89
148
|
end
|
90
149
|
|
91
150
|
#
|
92
|
-
# Checks whether we're on a proper version of
|
93
|
-
#
|
151
|
+
# Checks whether we're on a proper version of Ruby (likely 1.9+) which
|
152
|
+
# provides coverage support
|
94
153
|
#
|
95
154
|
def usable?
|
96
|
-
|
97
|
-
|
98
|
-
|
155
|
+
return @usable if defined?(@usable) && !@usable.nil?
|
156
|
+
|
157
|
+
@usable = begin
|
158
|
+
require "coverage"
|
159
|
+
require "simplecov/jruby_fix"
|
160
|
+
true
|
161
|
+
rescue LoadError
|
162
|
+
false
|
99
163
|
end
|
100
|
-
|
164
|
+
end
|
165
|
+
|
166
|
+
#
|
167
|
+
# Clear out the previously cached .result. Primarily useful in testing
|
168
|
+
#
|
169
|
+
def clear_result
|
170
|
+
@result = nil
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Capture the current exception if it exists
|
175
|
+
# This will get called inside the at_exit block
|
176
|
+
#
|
177
|
+
def set_exit_exception
|
178
|
+
@exit_exception = $ERROR_INFO
|
179
|
+
end
|
180
|
+
|
181
|
+
#
|
182
|
+
# Returns the exit status from the exit exception
|
183
|
+
#
|
184
|
+
def exit_status_from_exception
|
185
|
+
return SimpleCov::ExitCodes::SUCCESS unless exit_exception
|
186
|
+
|
187
|
+
if exit_exception.is_a?(SystemExit)
|
188
|
+
exit_exception.status
|
189
|
+
else
|
190
|
+
SimpleCov::ExitCodes::EXCEPTION
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# @api private
|
195
|
+
#
|
196
|
+
# Called from at_exit block
|
197
|
+
#
|
198
|
+
def run_exit_tasks!
|
199
|
+
exit_status = SimpleCov.exit_status_from_exception
|
200
|
+
|
201
|
+
SimpleCov.at_exit.call
|
202
|
+
|
203
|
+
# Don't modify the exit status unless the result has already been
|
204
|
+
# computed
|
205
|
+
exit_status = SimpleCov.process_result(SimpleCov.result, exit_status) if SimpleCov.result?
|
206
|
+
|
207
|
+
# Force exit with stored status (see github issue #5)
|
208
|
+
# unless it's nil or 0 (see github issue #281)
|
209
|
+
if exit_status && exit_status > 0
|
210
|
+
$stderr.printf("SimpleCov failed with exit %d", exit_status)
|
211
|
+
Kernel.exit exit_status
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# @api private
|
216
|
+
#
|
217
|
+
# Usage:
|
218
|
+
# exit_status = SimpleCov.process_result(SimpleCov.result, exit_status)
|
219
|
+
#
|
220
|
+
def process_result(result, exit_status)
|
221
|
+
return exit_status if exit_status != SimpleCov::ExitCodes::SUCCESS # Existing errors
|
222
|
+
|
223
|
+
covered_percent = result.covered_percent.round(2)
|
224
|
+
result_exit_status = result_exit_status(result, covered_percent)
|
225
|
+
if result_exit_status == SimpleCov::ExitCodes::SUCCESS # No result errors
|
226
|
+
write_last_run(covered_percent)
|
227
|
+
end
|
228
|
+
final_result_process? ? result_exit_status : SimpleCov::ExitCodes::SUCCESS
|
229
|
+
end
|
230
|
+
|
231
|
+
# @api private
|
232
|
+
#
|
233
|
+
# rubocop:disable Metrics/MethodLength
|
234
|
+
def result_exit_status(result, covered_percent)
|
235
|
+
covered_percentages = result.covered_percentages.map { |percentage| percentage.round(2) }
|
236
|
+
if covered_percent < SimpleCov.minimum_coverage
|
237
|
+
$stderr.printf("Coverage (%.2f%%) is below the expected minimum coverage (%.2f%%).\n", covered_percent, SimpleCov.minimum_coverage)
|
238
|
+
SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
239
|
+
elsif covered_percentages.any? { |p| p < SimpleCov.minimum_coverage_by_file }
|
240
|
+
$stderr.printf("File (%s) is only (%.2f%%) covered. This is below the expected minimum coverage per file of (%.2f%%).\n", result.least_covered_file, covered_percentages.min, SimpleCov.minimum_coverage_by_file)
|
241
|
+
SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
242
|
+
elsif (last_run = SimpleCov::LastRun.read)
|
243
|
+
coverage_diff = last_run["result"]["covered_percent"] - covered_percent
|
244
|
+
if coverage_diff > SimpleCov.maximum_coverage_drop
|
245
|
+
$stderr.printf("Coverage has dropped by %.2f%% since the last time (maximum allowed: %.2f%%).\n", coverage_diff, SimpleCov.maximum_coverage_drop)
|
246
|
+
SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
247
|
+
else
|
248
|
+
SimpleCov::ExitCodes::SUCCESS
|
249
|
+
end
|
250
|
+
else
|
251
|
+
SimpleCov::ExitCodes::SUCCESS
|
252
|
+
end
|
253
|
+
end
|
254
|
+
# rubocop:enable Metrics/MethodLength
|
255
|
+
|
256
|
+
#
|
257
|
+
# @api private
|
258
|
+
#
|
259
|
+
def final_result_process?
|
260
|
+
# checking for ENV["TEST_ENV_NUMBER"] to determine if the tess are being run in parallel
|
261
|
+
!defined?(ParallelTests) || !ENV["TEST_ENV_NUMBER"] || ParallelTests.number_of_running_processes <= 1
|
262
|
+
end
|
263
|
+
|
264
|
+
#
|
265
|
+
# @api private
|
266
|
+
#
|
267
|
+
def wait_for_other_processes
|
268
|
+
return unless defined?(ParallelTests) && final_result_process?
|
269
|
+
ParallelTests.wait_for_other_processes_to_finish
|
270
|
+
end
|
271
|
+
|
272
|
+
#
|
273
|
+
# @api private
|
274
|
+
#
|
275
|
+
def write_last_run(covered_percent)
|
276
|
+
SimpleCov::LastRun.write(:result => {:covered_percent => covered_percent})
|
101
277
|
end
|
102
278
|
end
|
103
279
|
end
|
104
280
|
|
105
281
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
106
|
-
require
|
282
|
+
require "simplecov/configuration"
|
107
283
|
SimpleCov.send :extend, SimpleCov::Configuration
|
108
|
-
require
|
109
|
-
require
|
110
|
-
require
|
111
|
-
require
|
112
|
-
require
|
113
|
-
require
|
114
|
-
require
|
115
|
-
require
|
116
|
-
require
|
117
|
-
require
|
284
|
+
require "simplecov/exit_codes"
|
285
|
+
require "simplecov/profiles"
|
286
|
+
require "simplecov/source_file"
|
287
|
+
require "simplecov/file_list"
|
288
|
+
require "simplecov/result"
|
289
|
+
require "simplecov/filter"
|
290
|
+
require "simplecov/formatter"
|
291
|
+
require "simplecov/last_run"
|
292
|
+
require "simplecov/lines_classifier"
|
293
|
+
require "simplecov/raw_coverage"
|
294
|
+
require "simplecov/result_merger"
|
295
|
+
require "simplecov/command_guesser"
|
296
|
+
require "simplecov/version"
|
118
297
|
|
119
298
|
# Load default config
|
120
|
-
require
|
299
|
+
require "simplecov/defaults" unless ENV["SIMPLECOV_NO_DEFAULTS"]
|
121
300
|
|
122
301
|
# Load Rails integration (only for Rails 3, see #113)
|
123
|
-
require
|
302
|
+
require "simplecov/railtie" if defined? Rails::Railtie
|
@@ -1,49 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#
|
2
4
|
# Helper that tries to find out what test suite is running (for SimpleCov.command_name)
|
3
5
|
#
|
4
|
-
module SimpleCov
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
module SimpleCov
|
7
|
+
module CommandGuesser
|
8
|
+
class << self
|
9
|
+
# Storage for the original command line call that invoked the test suite.
|
10
|
+
# This has got to be stored as early as possible because i.e. rake and test/unit 2
|
11
|
+
# have a habit of tampering with ARGV, which makes i.e. the automatic distinction
|
12
|
+
# between rails unit/functional/integration tests impossible without this cached
|
13
|
+
# item.
|
14
|
+
attr_accessor :original_run_command
|
15
|
+
|
16
|
+
def guess
|
17
|
+
from_env || from_command_line_options || from_defined_constants
|
18
|
+
end
|
19
|
+
|
17
20
|
private
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
|
22
|
+
def from_env
|
23
|
+
# If being run from inside parallel_tests set the command name according to the process number
|
24
|
+
return unless ENV["PARALLEL_TEST_GROUPS"] && ENV["TEST_ENV_NUMBER"]
|
25
|
+
number = ENV["TEST_ENV_NUMBER"]
|
26
|
+
number = "1" if number.empty?
|
27
|
+
"(#{number}/#{ENV['PARALLEL_TEST_GROUPS']})"
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_command_line_options
|
31
|
+
case original_run_command
|
32
|
+
when /test\/functional\//, /test\/\{.*functional.*\}\//
|
22
33
|
"Functional Tests"
|
23
|
-
when
|
34
|
+
when /test\/integration\//
|
24
35
|
"Integration Tests"
|
25
|
-
when
|
36
|
+
when /test\//
|
26
37
|
"Unit Tests"
|
38
|
+
when /spec/
|
39
|
+
"RSpec"
|
27
40
|
when /cucumber/, /features/
|
28
41
|
"Cucumber Features"
|
29
|
-
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def from_defined_constants
|
46
|
+
# If the command regexps fail, let's try checking defined constants.
|
47
|
+
if defined?(RSpec)
|
30
48
|
"RSpec"
|
49
|
+
elsif defined?(Test::Unit)
|
50
|
+
"Unit Tests"
|
51
|
+
elsif defined?(MiniTest)
|
52
|
+
"MiniTest"
|
31
53
|
else
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def from_defined_constants
|
37
|
-
# If the command regexps fail, let's try checking defined constants.
|
38
|
-
if defined?(RSpec)
|
39
|
-
"RSpec"
|
40
|
-
elsif defined?(Test::Unit)
|
41
|
-
"Unit Tests"
|
42
|
-
else
|
43
|
-
# TODO: Provide link to docs/wiki article
|
44
|
-
warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
|
45
|
-
'Unknown Test Framework'
|
54
|
+
# TODO: Provide link to docs/wiki article
|
55
|
+
warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
|
56
|
+
"Unknown Test Framework"
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
49
|
-
end
|
61
|
+
end
|