-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cope with Rcov giving different lines for coverage with Ruby 1.8 and 1.9
- Loading branch information
1 parent
79b0104
commit 9b33a30
Showing
6 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
default: --profile 1_8 | ||
1_8: --tags ~@ruby_1_9 | ||
1_9: --tags @ruby_1_9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'rbconfig' | ||
|
||
module Cucover | ||
module LineNumbers | ||
# Different Ruby versions have slightly different line numbers with rcov | ||
def self.offset | ||
Config::CONFIG['MINOR'] == '9' ? 0 : 1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
module Cucover | ||
class Recording::CoveredFile | ||
attr_reader :file | ||
|
||
def initialize(full_filename, rcov_marked_info, recording) | ||
@full_filename = full_filename | ||
@rcov_marked_info = rcov_marked_info | ||
@recording = recording | ||
@file = File.expand_path(full_filename).gsub(/^#{Dir.pwd}\//, '') | ||
|
||
extend HasLineNumberDetail if @rcov_marked_info | ||
end | ||
|
||
def dirty? | ||
Cucover.logger.debug("#{file} last modified at #{File.mtime(@full_filename)}") | ||
Cucover.logger.debug("#{file} recording started at #{@recording.start_time}") | ||
result = File.mtime(@full_filename).to_i >= @recording.start_time.to_i | ||
Cucover.logger.debug("verdict: #{(result ? "dirty" : "not dirty")}") | ||
result | ||
end | ||
|
||
def covers_line?(line_number) | ||
covered_lines.include?(line_number) | ||
end | ||
|
||
def ==(other) | ||
other == file | ||
end | ||
|
||
def to_s | ||
"#{file}:#{covered_lines.join(':')}" | ||
end | ||
|
||
private | ||
|
||
def covered_lines | ||
['<unknown lines>'] | ||
end | ||
|
||
module HasLineNumberDetail | ||
def covered_lines | ||
return @covered_lines if @covered_lines | ||
|
||
@covered_lines = [] | ||
@rcov_marked_info.each_with_index do |covered, index| | ||
line_number = index + 1 | ||
line_number = index + Cucover::LineNumbers.offset | ||
@covered_lines << line_number if covered | ||
end | ||
@covered_lines | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
require 'rubygems' | ||
|
||
gem 'logging', '>= 1.1.4' | ||
gem 'logging', '>= 1.4.1' | ||
require 'logging' | ||
|
||
gem 'cucumber', '>= 0.3.1' | ||
require 'cucumber' | ||
|
||
gem 'relevance-rcov','>= 0.8.3.4' | ||
gem 'rcov', '>= 0.9.8' | ||
require 'rcov' |