single_cov 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/single_cov/version.rb +1 -1
- data/lib/single_cov.rb +35 -13
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b02d2e0301ceb4d611d5b5d543f3715971f69a44b5ba200a47c9f705dc013e1
|
|
4
|
+
data.tar.gz: 6a916a1ff4b8232e7132e731b92b157e500537c0c324489e4e10df52ba49a54c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 905ea1116dfa415a892cbddfbc1b67ffcefd113036b491c544589be016a13ae6264ffe2ff4a5d335db7f91e62661639b62855d5f0c276ace4789aa92b468e110
|
|
7
|
+
data.tar.gz: 16161caf77b469e861b82852ca3b87ec0a7f45b443c1dc2b093cb4180c892be1bf2d3409448d2574d3d4567c20061947ea1d730a476a17fcb3e14c91ef41bd0f
|
data/lib/single_cov/version.rb
CHANGED
data/lib/single_cov.rb
CHANGED
|
@@ -10,6 +10,16 @@ module SingleCov
|
|
|
10
10
|
SIMPLECOV_ENABLE_BLOCK_MARKER = /^\s*#\s*simplecov:enable\b/
|
|
11
11
|
PREFIXES_TO_IGNORE = [] # things to not prefix with lib/ etc
|
|
12
12
|
|
|
13
|
+
# fails the minitest run when coverage is missing
|
|
14
|
+
module MinitestReporter
|
|
15
|
+
attr_writer :single_cov_options
|
|
16
|
+
|
|
17
|
+
# minitest only calls this once all tests finished, so interrupted runs are not reported
|
|
18
|
+
def passed?
|
|
19
|
+
super && SingleCov.send(:minitest_report_passed?, @single_cov_options)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
13
23
|
class << self
|
|
14
24
|
# enable coverage reporting: path to output file, changed by forking-test-runner at runtime to combine many reports
|
|
15
25
|
attr_accessor :coverage_report
|
|
@@ -127,7 +137,7 @@ module SingleCov
|
|
|
127
137
|
|
|
128
138
|
case framework
|
|
129
139
|
when :minitest
|
|
130
|
-
return if minitest_running_subset_of_tests?(ARGV)
|
|
140
|
+
return if minitest_running_subset_of_tests?(ARGV, {})
|
|
131
141
|
when :rspec
|
|
132
142
|
return if rspec_running_subset_of_tests?
|
|
133
143
|
else
|
|
@@ -138,17 +148,13 @@ module SingleCov
|
|
|
138
148
|
|
|
139
149
|
# minitest overrides at_exit, so we need to get into it to execute after it finishes
|
|
140
150
|
# so when using the `minitest` executable or loading minitest before SingleCov the first branch is used
|
|
141
|
-
if defined?(Minitest)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
end
|
|
149
|
-
result
|
|
150
|
-
end
|
|
151
|
-
end)
|
|
151
|
+
if framework == :minitest && defined?(Minitest)
|
|
152
|
+
# a plugin since setup can run inside of Minitest.run (rails 8.1+ loads tests in process_args)
|
|
153
|
+
Minitest.extensions |= ["single_cov"]
|
|
154
|
+
def Minitest.plugin_single_cov_init(options)
|
|
155
|
+
# override passed? on the composite since plugins like minitest-reporters replace its reporters
|
|
156
|
+
reporter.extend(SingleCov::MinitestReporter).single_cov_options = options
|
|
157
|
+
end
|
|
152
158
|
else
|
|
153
159
|
override_at_exit do |status, _exception|
|
|
154
160
|
if main_process? && status == 0 && !report_at_exit
|
|
@@ -280,8 +286,18 @@ module SingleCov
|
|
|
280
286
|
COVERAGES.size == 1
|
|
281
287
|
end
|
|
282
288
|
|
|
289
|
+
# @return [Boolean] false when coverage is missing
|
|
290
|
+
def minitest_report_passed?(options)
|
|
291
|
+
return true if minitest_running_subset_of_tests?(options[:args].to_s.split, options)
|
|
292
|
+
|
|
293
|
+
report_at_exit != false # nil when disabled
|
|
294
|
+
end
|
|
295
|
+
|
|
283
296
|
# do not record or verify when only running selected tests since it would be missing data
|
|
284
|
-
def minitest_running_subset_of_tests?(argv)
|
|
297
|
+
def minitest_running_subset_of_tests?(argv, options)
|
|
298
|
+
# via parsed options: -n is :filter in MT 5 or :include in MT 6, -e is :exclude
|
|
299
|
+
options[:filter] || options[:include] || options[:exclude] ||
|
|
300
|
+
|
|
285
301
|
# via direct option (ruby test.rb -n /foo/)
|
|
286
302
|
# or `minitest foo.rb:123` which is translated to -n
|
|
287
303
|
argv.map { |a| a.split('=', 2).first }.intersect?(['-n', '--name', '-l', '--line']) ||
|
|
@@ -295,6 +311,12 @@ module SingleCov
|
|
|
295
311
|
Minitest.reporter &&
|
|
296
312
|
(reporter = Minitest.reporter.reporters.first) &&
|
|
297
313
|
(reporter.options[:filter] || reporter.options[:include]) # MT 5 vs MT 6
|
|
314
|
+
) ||
|
|
315
|
+
|
|
316
|
+
# via rails 8.1+ test with line numbers, which rails filters itself
|
|
317
|
+
(
|
|
318
|
+
defined?(Rails::TestUnit::Runner) &&
|
|
319
|
+
Rails::TestUnit::Runner.filters.any? { |_file, lines| lines.any? }
|
|
298
320
|
)
|
|
299
321
|
end
|
|
300
322
|
|