Skip to content

Commit

Permalink
nil out :nocov: sections in coverage results
Browse files Browse the repository at this point in the history
* version bump
  • Loading branch information
nickmerwin committed Nov 4, 2015
1 parent 8138801 commit 28014a7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 30 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ platform :rbx do
gem 'json'
gem 'rubinius-developer_tools'
end

group :test do
gem 'pry'
end
48 changes: 22 additions & 26 deletions lib/coveralls/simplecov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ def display_result(result)
true
end

def format(result)

unless Coveralls.should_run?
if Coveralls.noisy?
display_result result
end
return
end

def get_source_files(result)
# Gather the source files.
source_files = []
result.files.each do |file|
Expand All @@ -47,29 +39,33 @@ def format(result)
properties[:name] = short_filename(file.filename)

# Get the coverage
properties[:coverage] = file.coverage

# Get the group
# puts "result groups: #{result.groups}"
# result.groups.each do |group_name, grouped_files|
# puts "Checking #{grouped_files.map(&:filename)} for #{file.filename}"
# if grouped_files.map(&:filename).include?(file.filename)
# properties[:group] = group_name
# break
# end
# end
properties[:coverage] = file.coverage.dup

# Skip nocov lines
file.lines.each_with_index do |line, i|
properties[:coverage][i] = nil if line.skipped?
end

source_files << properties
end
source_files
end

def format(result)

# Log which files are being submitted.
# puts "Submitting #{source_files.length} file#{source_files.length == 1 ? '' : 's'}:"
# source_files.each do |f|
# puts " => #{f[:name]}"
# end
unless Coveralls.should_run?
if Coveralls.noisy?
display_result result
end
return
end

# Post to Coveralls.
API.post_json "jobs", {:source_files => source_files, :test_framework => result.command_name.downcase, :run_at => result.created_at}
API.post_json "jobs",
source_files: get_source_files(result),
test_framework: result.command_name.downcase,
run_at: result.created_at

Coveralls::Output.puts output_message result

true
Expand Down
2 changes: 1 addition & 1 deletion lib/coveralls/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Coveralls
VERSION = "0.8.3"
VERSION = "0.8.4"
end
6 changes: 4 additions & 2 deletions spec/coveralls/fixtures/app/controllers/sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ class Foo
def initialize
@foo = 'baz'
end


# :nocov:
def bar
@foo
end
end
# :nocov:
end
2 changes: 2 additions & 0 deletions spec/coveralls/fixtures/sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ def initialize
@foo = 'baz'
end

# :nocov:
def bar
@foo
end
# :nocov:
end
10 changes: 9 additions & 1 deletion spec/coveralls/simplecov_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def source_fixture(filename)
source_fixture( 'app/models/house.rb' ) => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],
source_fixture( 'app/models/airplane.rb' ) => [0, 0, 0, 0, 0],
source_fixture( 'app/models/dog.rb' ) => [1, 1, 1, 1, 1],
source_fixture( 'app/controllers/sample.rb' ) => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil]
source_fixture( 'app/controllers/sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil]
})
}

Expand Down Expand Up @@ -69,5 +69,13 @@ def source_fixture(filename)
end
end

context "#get_source_files" do
let(:source_files) { Coveralls::SimpleCov::Formatter.new.get_source_files(result) }
it "nils the skipped lines" do
source_file = source_files.first
source_file[:coverage].should_not eq result.files.first.coverage
source_file[:coverage].should eq [nil, 1, 1, 1, nil, 0, 1, nil, nil, nil]
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'simplecov'
require 'webmock'
require 'vcr'
require 'pry'

class InceptionFormatter
def format(result)
Expand Down

0 comments on commit 28014a7

Please sign in to comment.