simplecov 0.15.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +116 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +302 -116
- data/doc/alternate-formatters.md +20 -0
- data/lib/simplecov.rb +321 -45
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +24 -0
- data/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/lib/simplecov/combine/results_combiner.rb +60 -0
- data/lib/simplecov/command_guesser.rb +8 -3
- data/lib/simplecov/configuration.rb +112 -9
- data/lib/simplecov/coverage_statistics.rb +56 -0
- data/lib/simplecov/defaults.rb +13 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +68 -13
- data/lib/simplecov/filter.rb +5 -2
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/formatter/multi_formatter.rb +4 -2
- data/lib/simplecov/formatter/simple_formatter.rb +6 -4
- data/lib/simplecov/last_run.rb +5 -1
- data/lib/simplecov/lines_classifier.rb +21 -5
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles.rb +11 -7
- 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/result.rb +41 -6
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +20 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +225 -126
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/useless_results_remover.rb +16 -0
- data/lib/simplecov/version.rb +3 -1
- metadata +43 -160
- data/.gitignore +0 -31
- data/.rspec +0 -3
- data/.rubocop.yml +0 -88
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/Gemfile +0 -38
- data/Rakefile +0 -39
- data/cucumber.yml +0 -13
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -45
- data/features/config_coverage_dir.feature +0 -33
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_formatters.feature +0 -77
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_profiles.feature +0 -44
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -121
- data/features/config_tracked_files.feature +0 -29
- data/features/config_tracked_files_relevant_lines.feature +0 -31
- data/features/cucumber_basic.feature +0 -29
- data/features/maximum_coverage_drop.feature +0 -89
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/minimum_coverage.feature +0 -59
- data/features/refuse_coverage_drop.feature +0 -95
- data/features/rspec_basic.feature +0 -32
- 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 -37
- data/features/rspec_groups_using_filter_class.feature +0 -41
- 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 -44
- data/features/step_definitions/simplecov_steps.rb +0 -68
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/aruba_freedom_patch.rb +0 -53
- data/features/support/env.rb +0 -50
- 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/lib/simplecov/jruby_fix.rb +0 -42
- data/lib/simplecov/railtie.rb +0 -7
- data/lib/simplecov/railties/tasks.rake +0 -11
- data/lib/simplecov/raw_coverage.rb +0 -39
- data/simplecov.gemspec +0 -27
- data/spec/1_8_fallbacks_spec.rb +0 -31
- data/spec/command_guesser_spec.rb +0 -48
- data/spec/config_loader_spec.rb +0 -14
- data/spec/configuration_spec.rb +0 -35
- data/spec/defaults_spec.rb +0 -41
- data/spec/deleted_source_spec.rb +0 -12
- data/spec/faked_project/Gemfile +0 -6
- data/spec/faked_project/Rakefile +0 -8
- data/spec/faked_project/cucumber.yml +0 -13
- data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
- data/spec/faked_project/features/support/env.rb +0 -12
- data/spec/faked_project/features/test_stuff.feature +0 -6
- data/spec/faked_project/lib/faked_project.rb +0 -11
- data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
- data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
- data/spec/faked_project/spec/faked_spec.rb +0 -11
- data/spec/faked_project/spec/forking_spec.rb +0 -8
- data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
- data/spec/faked_project/spec/some_class_spec.rb +0 -13
- data/spec/faked_project/spec/spec_helper.rb +0 -11
- data/spec/faked_project/test/faked_test.rb +0 -11
- data/spec/faked_project/test/meta_magic_test.rb +0 -13
- data/spec/faked_project/test/some_class_test.rb +0 -15
- data/spec/faked_project/test/test_helper.rb +0 -12
- data/spec/file_list_spec.rb +0 -50
- data/spec/filters_spec.rb +0 -202
- data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
- data/spec/fixtures/app/models/user.rb +0 -10
- data/spec/fixtures/deleted_source_sample.rb +0 -15
- data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
- data/spec/fixtures/frameworks/rspec_good.rb +0 -9
- data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
- data/spec/fixtures/frameworks/testunit_good.rb +0 -9
- data/spec/fixtures/iso-8859.rb +0 -3
- data/spec/fixtures/never.rb +0 -2
- data/spec/fixtures/resultset1.rb +0 -4
- data/spec/fixtures/resultset2.rb +0 -4
- data/spec/fixtures/sample.rb +0 -16
- data/spec/fixtures/skipped.rb +0 -4
- data/spec/fixtures/skipped_and_executed.rb +0 -8
- data/spec/fixtures/utf-8.rb +0 -3
- data/spec/helper.rb +0 -26
- data/spec/last_run_spec.rb +0 -48
- data/spec/lines_classifier_spec.rb +0 -103
- data/spec/multi_formatter_spec.rb +0 -20
- data/spec/raw_coverage_spec.rb +0 -92
- data/spec/result_merger_spec.rb +0 -171
- data/spec/result_spec.rb +0 -209
- data/spec/return_codes_spec.rb +0 -34
- data/spec/simplecov_spec.rb +0 -109
- data/spec/source_file_line_spec.rb +0 -155
- data/spec/source_file_spec.rb +0 -145
- data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
data/spec/source_file_spec.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
if SimpleCov.usable?
|
4
|
-
describe SimpleCov::SourceFile do
|
5
|
-
COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
|
6
|
-
context "a source file initialized with some coverage data" do
|
7
|
-
subject do
|
8
|
-
SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "has a filename" do
|
12
|
-
expect(subject.filename).not_to be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has source equal to src" do
|
16
|
-
expect(subject.src).to eq(subject.source)
|
17
|
-
end
|
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
|
-
|
23
|
-
it "has source_lines equal to lines" do
|
24
|
-
expect(subject.lines).to eq(subject.source_lines)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "has 16 source lines" do
|
28
|
-
expect(subject.lines.count).to eq(16)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "has all source lines of type SimpleCov::SourceFile::Line" do
|
32
|
-
subject.lines.each do |line|
|
33
|
-
expect(line).to be_a SimpleCov::SourceFile::Line
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "has 'class Foo' as line(2).source" do
|
38
|
-
expect(subject.line(2).source).to eq("class Foo\n")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns lines number 2, 3, 4, 7 for covered_lines" do
|
42
|
-
expect(subject.covered_lines.map(&:line)).to eq([2, 3, 4, 7])
|
43
|
-
end
|
44
|
-
|
45
|
-
it "returns lines number 8 for missed_lines" do
|
46
|
-
expect(subject.missed_lines.map(&:line)).to eq([8])
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns lines number 1, 5, 6, 9, 10, 16 for never_lines" do
|
50
|
-
expect(subject.never_lines.map(&:line)).to eq([1, 5, 6, 9, 10, 16])
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns line numbers 11, 12, 13, 14, 15 for skipped_lines" do
|
54
|
-
expect(subject.skipped_lines.map(&:line)).to eq([11, 12, 13, 14, 15])
|
55
|
-
end
|
56
|
-
|
57
|
-
it "has 80% covered_percent" do
|
58
|
-
expect(subject.covered_percent).to eq(80.0)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "simulating potential Ruby 1.9 defect -- see Issue #56" do
|
63
|
-
subject do
|
64
|
-
SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB + [nil])
|
65
|
-
end
|
66
|
-
|
67
|
-
it "has 16 source lines regardless of extra data in coverage array" do
|
68
|
-
# Do not litter test output with known warning
|
69
|
-
capture_stderr { expect(subject.lines.count).to eq(16) }
|
70
|
-
end
|
71
|
-
|
72
|
-
it "prints a warning to stderr if coverage array contains more data than lines in the file" do
|
73
|
-
captured_output = capture_stderr do
|
74
|
-
subject.lines
|
75
|
-
end
|
76
|
-
|
77
|
-
expect(captured_output).to match(/^Warning: coverage data provided/)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "a file that is never relevant" do
|
82
|
-
COVERAGE_FOR_NEVER_RB = [nil, nil].freeze
|
83
|
-
|
84
|
-
subject do
|
85
|
-
SimpleCov::SourceFile.new(source_fixture("never.rb"), COVERAGE_FOR_NEVER_RB)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "has 0.0 covered_strength" do
|
89
|
-
expect(subject.covered_strength).to eq 0.0
|
90
|
-
end
|
91
|
-
|
92
|
-
it "has 0.0 covered_percent" do
|
93
|
-
expect(subject.covered_percent).to eq 100.0
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "a file where nothing is ever executed mixed with skipping #563" do
|
98
|
-
COVERAGE_FOR_SKIPPED_RB = [nil, nil, nil, nil].freeze
|
99
|
-
|
100
|
-
subject do
|
101
|
-
SimpleCov::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "has 0.0 covered_strength" do
|
105
|
-
expect(subject.covered_strength).to eq 0.0
|
106
|
-
end
|
107
|
-
|
108
|
-
it "has 0.0 covered_percent" do
|
109
|
-
expect(subject.covered_percent).to eq 0.0
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "a file where everything is skipped and missed #563" do
|
114
|
-
COVERAGE_FOR_SKIPPED_RB_2 = [nil, nil, 0, nil].freeze
|
115
|
-
|
116
|
-
subject do
|
117
|
-
SimpleCov::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB_2)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "has 0.0 covered_strength" do
|
121
|
-
expect(subject.covered_strength).to eq 0.0
|
122
|
-
end
|
123
|
-
|
124
|
-
it "has 0.0 covered_percent" do
|
125
|
-
expect(subject.covered_percent).to eq 0.0
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "a file where everything is skipped/irrelevamt but executed #563" do
|
130
|
-
COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB = [nil, nil, 1, 1, 0, nil, nil, nil].freeze
|
131
|
-
|
132
|
-
subject do
|
133
|
-
SimpleCov::SourceFile.new(source_fixture("skipped_and_executed.rb"), COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
|
134
|
-
end
|
135
|
-
|
136
|
-
it "has 0.0 covered_strength" do
|
137
|
-
expect(subject.covered_strength).to eq 0.0
|
138
|
-
end
|
139
|
-
|
140
|
-
it "has 0.0 covered_percent" do
|
141
|
-
expect(subject.covered_percent).to eq 0.0
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# Borrowed and heavily adjusted from:
|
2
|
-
# https://github.com/metricfu/metric_fu/blob/master/spec/capture_warnings.rb
|
3
|
-
require "fileutils"
|
4
|
-
|
5
|
-
class FailOnWarnings
|
6
|
-
def initialize
|
7
|
-
@stderr_stream = StringIO.new
|
8
|
-
@app_root = Dir.pwd
|
9
|
-
end
|
10
|
-
|
11
|
-
def collect_warnings
|
12
|
-
$stderr = @stderr_stream
|
13
|
-
$VERBOSE = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def process_warnings
|
17
|
-
lines = close_stream
|
18
|
-
app_warnings, other_warnings = split_lines(lines)
|
19
|
-
|
20
|
-
print_own_warnings(app_warnings) if app_warnings.any?
|
21
|
-
write_other_warnings_to_tmp(other_warnings) if other_warnings.any?
|
22
|
-
fail_script(app_warnings) if app_warnings.any?
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def close_stream
|
28
|
-
$stderr = STDERR
|
29
|
-
|
30
|
-
@stderr_stream.rewind
|
31
|
-
lines = @stderr_stream.read.split("\n")
|
32
|
-
lines.uniq!
|
33
|
-
@stderr_stream.close
|
34
|
-
lines
|
35
|
-
end
|
36
|
-
|
37
|
-
def split_lines(lines)
|
38
|
-
lines.partition { |line| line.include?(@app_root) }
|
39
|
-
end
|
40
|
-
|
41
|
-
def print_own_warnings(app_warnings)
|
42
|
-
puts ""
|
43
|
-
puts ""
|
44
|
-
puts <<-WARNINGS
|
45
|
-
#{'-' * 30} app warnings: #{'-' * 30}
|
46
|
-
#{app_warnings.join("\n")}
|
47
|
-
#{'-' * 75}
|
48
|
-
WARNINGS
|
49
|
-
end
|
50
|
-
|
51
|
-
def write_other_warnings_to_tmp(other_warnings)
|
52
|
-
output_dir = File.join(@app_root, "tmp")
|
53
|
-
FileUtils.mkdir_p(output_dir)
|
54
|
-
output_file = File.join(output_dir, "warnings.txt")
|
55
|
-
File.open(output_file, "w") do |file|
|
56
|
-
file.write(other_warnings.join("\n") << "\n")
|
57
|
-
end
|
58
|
-
puts
|
59
|
-
puts "Non-app warnings written to tmp/warnings.txt"
|
60
|
-
puts
|
61
|
-
end
|
62
|
-
|
63
|
-
def fail_script(app_warnings)
|
64
|
-
abort "Failing build due to app warnings: #{app_warnings.inspect}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
warning_collector = FailOnWarnings.new
|
69
|
-
warning_collector.collect_warnings
|
70
|
-
|
71
|
-
RSpec.configure do |config|
|
72
|
-
config.after(:suite) do
|
73
|
-
warning_collector.process_warnings
|
74
|
-
end
|
75
|
-
end
|