Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master', remote-tracking branch 'origin' into 2.0.testing
- Loading branch information
Showing
37 changed files
with
687 additions
and
140 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
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
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,53 @@ | ||
module Coverage | ||
@coverage_tool = nil | ||
|
||
def self.start | ||
require 'tooling/coverage' | ||
|
||
@coverage_tool = Rubinius::Coverage.new | ||
@coverage_tool.start | ||
end | ||
|
||
def self.result | ||
return unless @coverage_tool | ||
|
||
map = @coverage_tool.stop.results | ||
|
||
kernel = File.dirname Rubinius::KERNEL_PATH | ||
|
||
coverage = Hash.new { |h, k| h[k] = [] } | ||
|
||
map.each do |id, attr| | ||
counts = attr[:counts] | ||
code = attr[:code] | ||
next unless code | ||
|
||
file = code.file.to_s | ||
next if file[0] == ?( | ||
file = File.join kernel, file unless file[0] == ?/ | ||
|
||
code.lines.to_a.drop(1).each_slice(2) do |line, _| | ||
next unless line > 0 | ||
next if coverage[file][line - 1] | ||
|
||
coverage[file][line - 1] = 0 | ||
end | ||
|
||
counts.each do |ip, count| | ||
line = code.line_from_ip(ip) | ||
next unless line > 0 | ||
|
||
coverage[file][line - 1] = count | ||
end | ||
end | ||
|
||
coverage.each do |file, counts| | ||
lines = File.open(file, "r") { |f| f.lines.count } | ||
next unless lines > 0 | ||
|
||
counts[lines - 1] = nil unless counts.size == lines | ||
end | ||
|
||
coverage | ||
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
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 @@ | ||
require 'tooling/coverage/coverage' |
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,38 @@ | ||
module Rubinius | ||
class Coverage | ||
def self.loaded(flag) | ||
@loaded = flag | ||
end | ||
|
||
def self.loaded? | ||
@loaded == true | ||
end | ||
|
||
def self.load | ||
return if loaded? | ||
|
||
Tooling.load File.expand_path("../ext/coverage", __FILE__) | ||
loaded true | ||
|
||
self | ||
end | ||
|
||
attr_reader :results | ||
|
||
def initialize | ||
self.class.load | ||
end | ||
|
||
def start | ||
Rubinius::Tooling.enable | ||
|
||
self | ||
end | ||
|
||
def stop | ||
@results = Rubinius::Tooling.disable | ||
|
||
self | ||
end | ||
end | ||
end |
Oops, something went wrong.