nano-fast-box 0.0.1
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 +7 -0
- data/nano-fast-box.gemspec +12 -0
- data/simplecov-0.22.0/CHANGELOG.md +191 -0
- data/simplecov-0.22.0/LICENSE +20 -0
- data/simplecov-0.22.0/README.md +974 -0
- data/simplecov-0.22.0/doc/alternate-formatters.md +71 -0
- data/simplecov-0.22.0/doc/commercial-services.md +25 -0
- data/simplecov-0.22.0/doc/editor-integration.md +18 -0
- data/simplecov-0.22.0/lib/minitest/simplecov_plugin.rb +15 -0
- data/simplecov-0.22.0/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/simplecov-0.22.0/lib/simplecov/combine/files_combiner.rb +24 -0
- data/simplecov-0.22.0/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/simplecov-0.22.0/lib/simplecov/combine/results_combiner.rb +60 -0
- data/simplecov-0.22.0/lib/simplecov/combine.rb +30 -0
- data/simplecov-0.22.0/lib/simplecov/command_guesser.rb +64 -0
- data/simplecov-0.22.0/lib/simplecov/configuration.rb +500 -0
- data/simplecov-0.22.0/lib/simplecov/coverage_statistics.rb +56 -0
- data/simplecov-0.22.0/lib/simplecov/default_formatter.rb +20 -0
- data/simplecov-0.22.0/lib/simplecov/defaults.rb +53 -0
- data/simplecov-0.22.0/lib/simplecov/exit_codes/exit_code_handling.rb +29 -0
- data/simplecov-0.22.0/lib/simplecov/exit_codes/maximum_coverage_drop_check.rb +83 -0
- data/simplecov-0.22.0/lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb +54 -0
- data/simplecov-0.22.0/lib/simplecov/exit_codes/minimum_overall_coverage_check.rb +53 -0
- data/simplecov-0.22.0/lib/simplecov/exit_codes.rb +15 -0
- data/simplecov-0.22.0/lib/simplecov/file_list.rb +120 -0
- data/simplecov-0.22.0/lib/simplecov/filter.rb +94 -0
- data/simplecov-0.22.0/lib/simplecov/formatter/multi_formatter.rb +32 -0
- data/simplecov-0.22.0/lib/simplecov/formatter/simple_formatter.rb +25 -0
- data/simplecov-0.22.0/lib/simplecov/formatter.rb +10 -0
- data/simplecov-0.22.0/lib/simplecov/last_run.rb +28 -0
- data/simplecov-0.22.0/lib/simplecov/lines_classifier.rb +48 -0
- data/simplecov-0.22.0/lib/simplecov/load_global_config.rb +8 -0
- data/simplecov-0.22.0/lib/simplecov/no_defaults.rb +4 -0
- data/simplecov-0.22.0/lib/simplecov/process.rb +19 -0
- data/simplecov-0.22.0/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/simplecov-0.22.0/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/simplecov-0.22.0/lib/simplecov/profiles/rails.rb +18 -0
- data/simplecov-0.22.0/lib/simplecov/profiles/root_filter.rb +10 -0
- data/simplecov-0.22.0/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/simplecov-0.22.0/lib/simplecov/profiles.rb +35 -0
- data/simplecov-0.22.0/lib/simplecov/result.rb +94 -0
- data/simplecov-0.22.0/lib/simplecov/result_adapter.rb +30 -0
- data/simplecov-0.22.0/lib/simplecov/result_merger.rb +194 -0
- data/simplecov-0.22.0/lib/simplecov/simulate_coverage.rb +29 -0
- data/simplecov-0.22.0/lib/simplecov/source_file/branch.rb +84 -0
- data/simplecov-0.22.0/lib/simplecov/source_file/line.rb +72 -0
- data/simplecov-0.22.0/lib/simplecov/source_file.rb +355 -0
- data/simplecov-0.22.0/lib/simplecov/useless_results_remover.rb +18 -0
- data/simplecov-0.22.0/lib/simplecov/version.rb +5 -0
- data/simplecov-0.22.0/lib/simplecov.rb +470 -0
- metadata +90 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module ExitCodes
|
|
5
|
+
class MaximumCoverageDropCheck
|
|
6
|
+
def initialize(result, maximum_coverage_drop)
|
|
7
|
+
@result = result
|
|
8
|
+
@maximum_coverage_drop = maximum_coverage_drop
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def failing?
|
|
12
|
+
return false unless maximum_coverage_drop && last_run
|
|
13
|
+
|
|
14
|
+
coverage_drop_violations.any?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def report
|
|
18
|
+
coverage_drop_violations.each do |violation|
|
|
19
|
+
$stderr.printf(
|
|
20
|
+
"%<criterion>s coverage has dropped by %<drop_percent>.2f%% since the last time (maximum allowed: %<max_drop>.2f%%).\n",
|
|
21
|
+
criterion: violation[:criterion].capitalize,
|
|
22
|
+
drop_percent: SimpleCov.round_coverage(violation[:drop_percent]),
|
|
23
|
+
max_drop: violation[:max_drop]
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def exit_code
|
|
29
|
+
SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
attr_reader :result, :maximum_coverage_drop
|
|
35
|
+
|
|
36
|
+
def last_run
|
|
37
|
+
return @last_run if defined?(@last_run)
|
|
38
|
+
|
|
39
|
+
@last_run = SimpleCov::LastRun.read
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def coverage_drop_violations
|
|
43
|
+
@coverage_drop_violations ||=
|
|
44
|
+
compute_coverage_drop_data.select do |achieved|
|
|
45
|
+
achieved.fetch(:max_drop) < achieved.fetch(:drop_percent)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def compute_coverage_drop_data
|
|
50
|
+
maximum_coverage_drop.map do |criterion, percent|
|
|
51
|
+
{
|
|
52
|
+
criterion: criterion,
|
|
53
|
+
max_drop: percent,
|
|
54
|
+
drop_percent: drop_percent(criterion)
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# if anyone says "max_coverage_drop 0.000000000000000001" I appologize. Please don't.
|
|
60
|
+
MAX_DROP_ACCURACY = 10
|
|
61
|
+
def drop_percent(criterion)
|
|
62
|
+
drop = last_coverage(criterion) -
|
|
63
|
+
SimpleCov.round_coverage(
|
|
64
|
+
result.coverage_statistics.fetch(criterion).percent
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# floats, I tell ya.
|
|
68
|
+
# irb(main):001:0* 80.01 - 80.0
|
|
69
|
+
# => 0.010000000000005116
|
|
70
|
+
drop.floor(MAX_DROP_ACCURACY)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def last_coverage(criterion)
|
|
74
|
+
last_coverage_percent = last_run[:result][criterion]
|
|
75
|
+
|
|
76
|
+
# fallback for old file format
|
|
77
|
+
last_coverage_percent = last_run[:result][:covered_percent] if !last_coverage_percent && criterion == :line
|
|
78
|
+
|
|
79
|
+
last_coverage_percent || 0
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module ExitCodes
|
|
5
|
+
class MinimumCoverageByFileCheck
|
|
6
|
+
def initialize(result, minimum_coverage_by_file)
|
|
7
|
+
@result = result
|
|
8
|
+
@minimum_coverage_by_file = minimum_coverage_by_file
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def failing?
|
|
12
|
+
minimum_violations.any?
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def report
|
|
16
|
+
minimum_violations.each do |violation|
|
|
17
|
+
$stderr.printf(
|
|
18
|
+
"%<criterion>s coverage by file (%<covered>.2f%%) is below the expected minimum coverage (%<minimum_coverage>.2f%%).\n",
|
|
19
|
+
covered: SimpleCov.round_coverage(violation.fetch(:actual)),
|
|
20
|
+
minimum_coverage: violation.fetch(:minimum_expected),
|
|
21
|
+
criterion: violation.fetch(:criterion).capitalize
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def exit_code
|
|
27
|
+
SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
attr_reader :result, :minimum_coverage_by_file
|
|
33
|
+
|
|
34
|
+
def minimum_violations
|
|
35
|
+
@minimum_violations ||=
|
|
36
|
+
compute_minimum_coverage_data.select do |achieved|
|
|
37
|
+
achieved.fetch(:actual) < achieved.fetch(:minimum_expected)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def compute_minimum_coverage_data
|
|
42
|
+
minimum_coverage_by_file.flat_map do |criterion, expected_percent|
|
|
43
|
+
result.coverage_statistics_by_file.fetch(criterion).map do |actual_coverage|
|
|
44
|
+
{
|
|
45
|
+
criterion: criterion,
|
|
46
|
+
minimum_expected: expected_percent,
|
|
47
|
+
actual: SimpleCov.round_coverage(actual_coverage.percent)
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module ExitCodes
|
|
5
|
+
class MinimumOverallCoverageCheck
|
|
6
|
+
def initialize(result, minimum_coverage)
|
|
7
|
+
@result = result
|
|
8
|
+
@minimum_coverage = minimum_coverage
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def failing?
|
|
12
|
+
minimum_violations.any?
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def report
|
|
16
|
+
minimum_violations.each do |violation|
|
|
17
|
+
$stderr.printf(
|
|
18
|
+
"%<criterion>s coverage (%<covered>.2f%%) is below the expected minimum coverage (%<minimum_coverage>.2f%%).\n",
|
|
19
|
+
covered: SimpleCov.round_coverage(violation.fetch(:actual)),
|
|
20
|
+
minimum_coverage: violation.fetch(:minimum_expected),
|
|
21
|
+
criterion: violation.fetch(:criterion).capitalize
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def exit_code
|
|
27
|
+
SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
attr_reader :result, :minimum_coverage
|
|
33
|
+
|
|
34
|
+
def minimum_violations
|
|
35
|
+
@minimum_violations ||= calculate_minimum_violations
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def calculate_minimum_violations
|
|
39
|
+
coverage_achieved = minimum_coverage.map do |criterion, percent|
|
|
40
|
+
{
|
|
41
|
+
criterion: criterion,
|
|
42
|
+
minimum_expected: percent,
|
|
43
|
+
actual: result.coverage_statistics.fetch(criterion).percent
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
coverage_achieved.select do |achieved|
|
|
48
|
+
achieved.fetch(:actual) < achieved.fetch(:minimum_expected)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module ExitCodes
|
|
5
|
+
SUCCESS = 0
|
|
6
|
+
EXCEPTION = 1
|
|
7
|
+
MINIMUM_COVERAGE = 2
|
|
8
|
+
MAXIMUM_COVERAGE_DROP = 3
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require_relative "exit_codes/exit_code_handling"
|
|
13
|
+
require_relative "exit_codes/maximum_coverage_drop_check"
|
|
14
|
+
require_relative "exit_codes/minimum_coverage_by_file_check"
|
|
15
|
+
require_relative "exit_codes/minimum_overall_coverage_check"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
# An array of SimpleCov SourceFile instances with additional collection helper
|
|
5
|
+
# methods for calculating coverage across them etc.
|
|
6
|
+
class FileList
|
|
7
|
+
include Enumerable
|
|
8
|
+
extend Forwardable
|
|
9
|
+
|
|
10
|
+
def_delegators :@files,
|
|
11
|
+
# For Enumerable
|
|
12
|
+
:each,
|
|
13
|
+
# also delegating methods implemented in Enumerable as they have
|
|
14
|
+
# custom Array implementations which are presumably better/more
|
|
15
|
+
# resource efficient
|
|
16
|
+
:size, :map, :count,
|
|
17
|
+
# surprisingly not in Enumerable
|
|
18
|
+
:empty?, :length,
|
|
19
|
+
# still act like we're kinda an array
|
|
20
|
+
:to_a, :to_ary
|
|
21
|
+
|
|
22
|
+
def initialize(files)
|
|
23
|
+
@files = files
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def coverage_statistics
|
|
27
|
+
@coverage_statistics ||= compute_coverage_statistics
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def coverage_statistics_by_file
|
|
31
|
+
@coverage_statistics_by_file ||= compute_coverage_statistics_by_file
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns the count of lines that have coverage
|
|
35
|
+
def covered_lines
|
|
36
|
+
coverage_statistics[:line]&.covered
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Returns the count of lines that have been missed
|
|
40
|
+
def missed_lines
|
|
41
|
+
coverage_statistics[:line]&.missed
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns the count of lines that are not relevant for coverage
|
|
45
|
+
def never_lines
|
|
46
|
+
return 0.0 if empty?
|
|
47
|
+
|
|
48
|
+
map { |f| f.never_lines.count }.inject(:+)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns the count of skipped lines
|
|
52
|
+
def skipped_lines
|
|
53
|
+
return 0.0 if empty?
|
|
54
|
+
|
|
55
|
+
map { |f| f.skipped_lines.count }.inject(:+)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Computes the coverage based upon lines covered and lines missed for each file
|
|
59
|
+
# Returns an array with all coverage percentages
|
|
60
|
+
def covered_percentages
|
|
61
|
+
map(&:covered_percent)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Finds the least covered file and returns that file's name
|
|
65
|
+
def least_covered_file
|
|
66
|
+
min_by(&:covered_percent).filename
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Returns the overall amount of relevant lines of code across all files in this list
|
|
70
|
+
def lines_of_code
|
|
71
|
+
coverage_statistics[:line]&.total
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Computes the coverage based upon lines covered and lines missed
|
|
75
|
+
# @return [Float]
|
|
76
|
+
def covered_percent
|
|
77
|
+
coverage_statistics[:line]&.percent
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Computes the strength (hits / line) based upon lines covered and lines missed
|
|
81
|
+
# @return [Float]
|
|
82
|
+
def covered_strength
|
|
83
|
+
coverage_statistics[:line]&.strength
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Return total count of branches in all files
|
|
87
|
+
def total_branches
|
|
88
|
+
coverage_statistics[:branch]&.total
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Return total count of covered branches
|
|
92
|
+
def covered_branches
|
|
93
|
+
coverage_statistics[:branch]&.covered
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Return total count of covered branches
|
|
97
|
+
def missed_branches
|
|
98
|
+
coverage_statistics[:branch]&.missed
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def branch_covered_percent
|
|
102
|
+
coverage_statistics[:branch]&.percent
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
private
|
|
106
|
+
|
|
107
|
+
def compute_coverage_statistics_by_file
|
|
108
|
+
@files.each_with_object(line: [], branch: []) do |file, together|
|
|
109
|
+
together[:line] << file.coverage_statistics.fetch(:line)
|
|
110
|
+
together[:branch] << file.coverage_statistics.fetch(:branch) if SimpleCov.branch_coverage?
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def compute_coverage_statistics
|
|
115
|
+
coverage_statistics = {line: CoverageStatistics.from(coverage_statistics_by_file[:line])}
|
|
116
|
+
coverage_statistics[:branch] = CoverageStatistics.from(coverage_statistics_by_file[:branch]) if SimpleCov.branch_coverage?
|
|
117
|
+
coverage_statistics
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
#
|
|
5
|
+
# Base filter class. Inherit from this to create custom filters,
|
|
6
|
+
# and overwrite the passes?(source_file) instance method
|
|
7
|
+
#
|
|
8
|
+
# # A sample class that rejects all source files.
|
|
9
|
+
# class StupidFilter < SimpleCov::Filter
|
|
10
|
+
# def passes?(source_file)
|
|
11
|
+
# false
|
|
12
|
+
# end
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
class Filter
|
|
16
|
+
attr_reader :filter_argument
|
|
17
|
+
|
|
18
|
+
def initialize(filter_argument)
|
|
19
|
+
@filter_argument = filter_argument
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def matches?(_source_file)
|
|
23
|
+
raise "The base filter class is not intended for direct use"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def passes?(source_file)
|
|
27
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #passes? is deprecated. Use #matches? instead."
|
|
28
|
+
matches?(source_file)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.build_filter(filter_argument)
|
|
32
|
+
return filter_argument if filter_argument.is_a?(SimpleCov::Filter)
|
|
33
|
+
|
|
34
|
+
class_for_argument(filter_argument).new(filter_argument)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.class_for_argument(filter_argument)
|
|
38
|
+
case filter_argument
|
|
39
|
+
when String
|
|
40
|
+
SimpleCov::StringFilter
|
|
41
|
+
when Regexp
|
|
42
|
+
SimpleCov::RegexFilter
|
|
43
|
+
when Array
|
|
44
|
+
SimpleCov::ArrayFilter
|
|
45
|
+
when Proc
|
|
46
|
+
SimpleCov::BlockFilter
|
|
47
|
+
else
|
|
48
|
+
raise ArgumentError, "You have provided an unrecognized filter type"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class StringFilter < SimpleCov::Filter
|
|
54
|
+
# Returns true when the given source file's filename matches the
|
|
55
|
+
# string configured when initializing this Filter with StringFilter.new('somestring')
|
|
56
|
+
def matches?(source_file)
|
|
57
|
+
source_file.project_filename.include?(filter_argument)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class RegexFilter < SimpleCov::Filter
|
|
62
|
+
# Returns true when the given source file's filename matches the
|
|
63
|
+
# regex configured when initializing this Filter with RegexFilter.new(/someregex/)
|
|
64
|
+
def matches?(source_file)
|
|
65
|
+
(source_file.project_filename =~ filter_argument)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class BlockFilter < SimpleCov::Filter
|
|
70
|
+
# Returns true if the block given when initializing this filter with BlockFilter.new {|src_file| ... }
|
|
71
|
+
# returns true for the given source file.
|
|
72
|
+
def matches?(source_file)
|
|
73
|
+
filter_argument.call(source_file)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class ArrayFilter < SimpleCov::Filter
|
|
78
|
+
def initialize(filter_argument)
|
|
79
|
+
filter_objects = filter_argument.map do |arg|
|
|
80
|
+
Filter.build_filter(arg)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
super(filter_objects)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Returns true if any of the filters in the array match the given source file.
|
|
87
|
+
# Configure this Filter like StringFilter.new(['some/path', /^some_regex/, Proc.new {|src_file| ... }])
|
|
88
|
+
def matches?(source_files_list)
|
|
89
|
+
filter_argument.any? do |arg|
|
|
90
|
+
arg.matches?(source_files_list)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module Formatter
|
|
5
|
+
class MultiFormatter
|
|
6
|
+
module InstanceMethods
|
|
7
|
+
def format(result)
|
|
8
|
+
formatters.map do |formatter|
|
|
9
|
+
formatter.new.format(result)
|
|
10
|
+
rescue StandardError => e
|
|
11
|
+
warn("Formatter #{formatter} failed with #{e.class}: #{e.message} (#{e.backtrace.first})")
|
|
12
|
+
nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.new(formatters = nil)
|
|
18
|
+
Class.new do
|
|
19
|
+
define_method :formatters do
|
|
20
|
+
@formatters ||= Array(formatters)
|
|
21
|
+
end
|
|
22
|
+
include InstanceMethods
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.[](*args)
|
|
27
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] ::[] is deprecated. Use ::new instead."
|
|
28
|
+
new(Array(args))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
module Formatter
|
|
5
|
+
#
|
|
6
|
+
# A ridiculously simple formatter for SimpleCov results.
|
|
7
|
+
#
|
|
8
|
+
class SimpleFormatter
|
|
9
|
+
# Takes a SimpleCov::Result and generates a string out of it
|
|
10
|
+
def format(result)
|
|
11
|
+
output = +""
|
|
12
|
+
result.groups.each do |name, files|
|
|
13
|
+
output << "Group: #{name}\n"
|
|
14
|
+
output << "=" * 40
|
|
15
|
+
output << "\n"
|
|
16
|
+
files.each do |file|
|
|
17
|
+
output << "#{file.filename} (coverage: #{file.covered_percent.round(2)}%)\n"
|
|
18
|
+
end
|
|
19
|
+
output << "\n"
|
|
20
|
+
end
|
|
21
|
+
output
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module SimpleCov
|
|
6
|
+
module LastRun
|
|
7
|
+
class << self
|
|
8
|
+
def last_run_path
|
|
9
|
+
File.join(SimpleCov.coverage_path, ".last_run.json")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def read
|
|
13
|
+
return nil unless File.exist?(last_run_path)
|
|
14
|
+
|
|
15
|
+
json = File.read(last_run_path)
|
|
16
|
+
return nil if json.strip.empty?
|
|
17
|
+
|
|
18
|
+
JSON.parse(json, symbolize_names: true)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def write(json)
|
|
22
|
+
File.open(last_run_path, "w+") do |f|
|
|
23
|
+
f.puts JSON.pretty_generate(json)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SimpleCov
|
|
4
|
+
# Classifies whether lines are relevant for code coverage analysis.
|
|
5
|
+
# Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
|
|
6
|
+
|
|
7
|
+
class LinesClassifier
|
|
8
|
+
RELEVANT = 0
|
|
9
|
+
NOT_RELEVANT = nil
|
|
10
|
+
|
|
11
|
+
WHITESPACE_LINE = /^\s*$/.freeze
|
|
12
|
+
COMMENT_LINE = /^\s*#/.freeze
|
|
13
|
+
WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE)
|
|
14
|
+
|
|
15
|
+
def self.no_cov_line
|
|
16
|
+
/^(\s*)#(\s*)(:#{SimpleCov.nocov_token}:)/o
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.no_cov_line?(line)
|
|
20
|
+
no_cov_line.match?(line)
|
|
21
|
+
rescue ArgumentError
|
|
22
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.whitespace_line?(line)
|
|
27
|
+
WHITESPACE_OR_COMMENT_LINE.match?(line)
|
|
28
|
+
rescue ArgumentError
|
|
29
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
|
30
|
+
false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def classify(lines)
|
|
34
|
+
skipping = false
|
|
35
|
+
|
|
36
|
+
lines.map do |line|
|
|
37
|
+
if self.class.no_cov_line?(line)
|
|
38
|
+
skipping = !skipping
|
|
39
|
+
NOT_RELEVANT
|
|
40
|
+
elsif skipping || self.class.whitespace_line?(line)
|
|
41
|
+
NOT_RELEVANT
|
|
42
|
+
else
|
|
43
|
+
RELEVANT
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "etc"
|
|
4
|
+
home_dir = (ENV["HOME"] && File.expand_path("~")) || Etc.getpwuid.dir || (ENV["USER"] && File.expand_path("~#{ENV['USER']}"))
|
|
5
|
+
if home_dir
|
|
6
|
+
global_config_path = File.join(home_dir, ".simplecov")
|
|
7
|
+
load global_config_path if File.exist?(global_config_path)
|
|
8
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Process
|
|
4
|
+
class << self
|
|
5
|
+
def fork_with_simplecov(&block)
|
|
6
|
+
if defined?(SimpleCov) && SimpleCov.running
|
|
7
|
+
fork_without_simplecov do
|
|
8
|
+
SimpleCov.at_fork.call(Process.pid)
|
|
9
|
+
block.call if block_given?
|
|
10
|
+
end
|
|
11
|
+
else
|
|
12
|
+
fork_without_simplecov(&block)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
alias fork_without_simplecov fork
|
|
17
|
+
alias fork fork_with_simplecov
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
SimpleCov.profiles.define "rails" do
|
|
4
|
+
load_profile "test_frameworks"
|
|
5
|
+
|
|
6
|
+
add_filter %r{^/config/}
|
|
7
|
+
add_filter %r{^/db/}
|
|
8
|
+
|
|
9
|
+
add_group "Controllers", "app/controllers"
|
|
10
|
+
add_group "Channels", "app/channels"
|
|
11
|
+
add_group "Models", "app/models"
|
|
12
|
+
add_group "Mailers", "app/mailers"
|
|
13
|
+
add_group "Helpers", "app/helpers"
|
|
14
|
+
add_group "Jobs", %w[app/jobs app/workers]
|
|
15
|
+
add_group "Libraries", "lib/"
|
|
16
|
+
|
|
17
|
+
track_files "{app,lib}/**/*.rb"
|
|
18
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
SimpleCov.profiles.define "root_filter" do
|
|
4
|
+
# Exclude all files outside of simplecov root
|
|
5
|
+
root_filter = nil
|
|
6
|
+
add_filter do |src|
|
|
7
|
+
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
|
|
8
|
+
src.filename !~ root_filter
|
|
9
|
+
end
|
|
10
|
+
end
|