Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/simplecov/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ def ensure_remove_undefs(file_lines)
end

def build_lines
coverage_exceeding_source_warn if coverage_data["lines"].size > src.size
lines = src.map.with_index(1) do |src, i|
SimpleCov::SourceFile::Line.new(src, i, coverage_data["lines"][i - 1])
end
Expand All @@ -272,11 +271,6 @@ def lines_strength
lines.sum { |line| line.coverage.to_i }
end

# Warning to identify condition from Issue #56
def coverage_exceeding_source_warn
warn "Warning: coverage data provided by Coverage [#{coverage_data['lines'].size}] exceeds number of lines in #{filename} [#{src.size}]"
end

#
# Build full branches report
# Root branches represent the wrapper of all condition state that
Expand Down
14 changes: 0 additions & 14 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,3 @@ def source_fixture(filename)
def source_fixture_base_directory
@source_fixture_base_directory ||= File.dirname(__FILE__)
end

# Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
def capture_stderr
# The output stream must be an IO-like object. In this case we capture it in
# an in-memory IO object so we can return the string value. You can assign any
# IO object here.
previous_stderr = $stderr
$stderr = StringIO.new
yield
$stderr.string
ensure
# Restore the previous value of stderr (typically equal to STDERR).
$stderr = previous_stderr
end
13 changes: 4 additions & 9 deletions spec/source_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,22 +356,17 @@
end
end

context "simulating potential Ruby 1.9 defect -- see Issue #56" do
context "when coverage data contains more entries than the source has lines" do
subject do
SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB_WITH_MORE_LINES)
end

it "has 16 source lines regardless of extra data in coverage array" do
# Do not litter test output with known warning
capture_stderr { expect(subject.lines.count).to eq(16) }
expect(subject.lines.count).to eq(16)
end

it "prints a warning to stderr if coverage array contains more data than lines in the file" do
captured_output = capture_stderr do
subject.lines
end

expect(captured_output).to match(/^Warning: coverage data provided/)
it "does not output to stderr" do
expect { subject.lines }.not_to output.to_stderr
end
end

Expand Down