Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatability with BINARY internal encoding #194

Merged
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
2 changes: 1 addition & 1 deletion lib/simplecov/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def status

def initialize(filename, coverage)
@filename, @coverage = filename, coverage
File.open(filename, "r:UTF-8") {|f| @src = f.readlines }
File.open(filename, "r:UTF-8:UTF-8") {|f| @src = f.readlines }
end

# Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
Expand Down
14 changes: 14 additions & 0 deletions test/test_source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ class TestSourceFile < Test::Unit::TestCase
source_file.process_skipped_lines!
end
end

should "handle utf-8 encoded source files when the default_internal encoding is binary" do
original_internal_encoding = Encoding.default_internal
Encoding.default_internal = "BINARY"
begin
source_file = SimpleCov::SourceFile.new(source_fixture('utf-8.rb'), [nil, nil, 1])
ensure
Encoding.default_internal = original_internal_encoding
end

assert_nothing_raised do
source_file.process_skipped_lines!
end
end
end

end
Expand Down