Skip to content

Commit

Permalink
Make sure filepaths are expanded on JRuby
Browse files Browse the repository at this point in the history
Fixes the build on JRuby
  • Loading branch information
infertux committed Feb 12, 2013
1 parent 0c87569 commit 6f71109
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion features/cucumber_basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature:
And I should see the source files:
| name | coverage |
| lib/faked_project.rb | 100.0 % |
| lib/faked_project/some_class.rb | 80.0 % |
| lib/faked_project/some_class.rb | 80.0 % |
| lib/faked_project/framework_specific.rb | 75.0 % |
| lib/faked_project/meta_magic.rb | 100.0 % |
| features/step_definitions/my_steps.rb | 100.0 % |
Expand Down
12 changes: 10 additions & 2 deletions lib/simplecov/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ class Result
# Initialize a new SimpleCov::Result from given Coverage.result (a Hash of filenames each containing an array of
# coverage data)
def initialize(original_result)
@original_result = original_result.freeze
@files = SimpleCov::FileList.new(original_result.map do |filename, coverage|
@original_result = original_result.dup

# Squeeze filepaths (i.e. "/a/b/../c" becomes "/a/c")
@original_result.keys.each do |filename|
expanded_filename = File.expand_path filename
@original_result[expanded_filename] = @original_result.delete filename
end

@files = SimpleCov::FileList.new(@original_result.map do |filename, coverage|
SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
end.compact.sort_by(&:filename))

filter!
end

Expand Down

0 comments on commit 6f71109

Please sign in to comment.