Defect #30967

"rake test:coverage" fails in Ruby 2.5 and 2.6

Added by Go MAEDA 18 days ago. Updated 13 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Ruby support
Target version:4.1.0
Resolution:Fixed Affected version:

Description

rake test:coverage fails in Ruby 2.5 or 2.6 with the error like the following. It occurs due to Unicode characters such as 'ŋ' in app/models/repository/git.rb line 3 and '汉' in lib/redmine/search.rb line 63.

Traceback (most recent call last):
    9: from /Users/maeda/redmines/gems/ruby/2.5.0/gems/simplecov-0.14.1/lib/simplecov/defaults.rb:68:in `block in <top (required)>'
    8: from /Users/maeda/redmines/gems/ruby/2.5.0/gems/simplecov-0.14.1/lib/simplecov/configuration.rb:180:in `block in at_exit'
    7: from /Users/maeda/redmines/gems/ruby/2.5.0/gems/simplecov-0.14.1/lib/simplecov/result.rb:46:in `format!'
    6: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:29:in `format'
    5: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:29:in `each'
    4: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:30:in `block in format'
    3: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:30:in `open'
    2: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:31:in `block (2 levels) in format'
    1: from /Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:31:in `puts'
/Users/maeda/redmines/redmine-trunk/test/coverage/html_formatter.rb:31:in `write': "\xC5" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

You can fix the error with the following change.

Index: test/coverage/html_formatter.rb
===================================================================
--- test/coverage/html_formatter.rb    (リビジョン 17927)
+++ test/coverage/html_formatter.rb    (作業コピー)
@@ -28,7 +28,7 @@
         end
         result.source_files.each do |source_file|
           File.open(File.join(output_path, source_file_result(source_file)), "w") do |file|
-            file.puts template('source').result(binding)
+            file.puts template('source').result(binding).force_encoding('utf-8')
           end
         end
       end

Related issues

Related to Redmine - Feature #30963: Update simplecov gem (~> 0.16.1) Closed

Associated revisions

Revision 17938
Added by Go MAEDA 13 days ago

"rake test:coverage" fails in Ruby 2.5 and 2.6 (#30967).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA 18 days ago

#2 Updated by Go MAEDA 15 days ago

  • Subject changed from rake test:coverage fails in Ruby 2.5 or 2.6 to rake test:coverage fails in Ruby 2.5 and 2.6
  • Target version changed from Candidate for next major release to 4.1.0

#3 Updated by Go MAEDA 13 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed.

#4 Updated by Go MAEDA 13 days ago

  • Subject changed from rake test:coverage fails in Ruby 2.5 and 2.6 to "rake test:coverage" fails in Ruby 2.5 and 2.6

Also available in: Atom PDF