Project

General

Profile

Actions

Patch #28112

closed

CsvTest fails due to a regression in Ruby 2.5

Added by Sho HASHIMOTO about 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Ruby support
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Ruby 2.5.0 at r17185 don't pass csv_test.rb:29.

Failure:
CsvTest#test_should_include_bom_when_utf8_encoded [/Users/sho-h/local/src/redmine/redmine.sho-h/test/unit/lib/redmine/export/csv_test.rb:29]:
Expected false to be truthy.

Maybe, the reason is regression in 2.5.0.

$ cat csvtest.rb

require 'csv'
bom = "\xEF\xBB\xBF" 
res1_1 = bom.dup
res1_2 = CSV.generate(res1_1, encoding: "UTF-8") {|csv| csv << %w(Foo Bar)}
p [bom, res1_1, res1_2]

res2_1 = "aa,bb" 
res2_2 = CSV.generate(res2_1, encoding: "UTF-8") {|csv| csv << %w(Foo Bar)}
p [bom, res2_1, res2_2]

$ rbenv each ruby -v csvtest.rb | more
...
ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-darwin15]
["<U+FEFF>", "<U+FEFF>Foo,Bar\n", "<U+FEFF>Foo,Bar\n"]
["<U+FEFF>", "aa,bbFoo,Bar\n", "aa,bbFoo,Bar\n"]
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin15]
["<U+FEFF>", "<U+FEFF>Foo,Bar\n", "<U+FEFF>Foo,Bar\n"]
["<U+FEFF>", "aa,bbFoo,Bar\n", "aa,bbFoo,Bar\n"]
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin15]
["<U+FEFF>", "Foo,Bar\n", "Foo,Bar\n"]
["<U+FEFF>", "Foo,Bar\n", "Foo,Bar\n"]

This problem was already reported below.

I attach patch to fix this problem. This patch don't use CSV.generate's first argument.


Files

redmine_with_ruby250.patch (954 Bytes) redmine_with_ruby250.patch Sho HASHIMOTO, 2018-01-31 12:08

Related issues

Related to Redmine - Defect #28689: csv 1.0.2 gem breaks ImportsControllerTest Closed

Actions
Blocks Redmine - Feature #27849: Ruby 2.5 supportClosedJean-Philippe Lang

Actions
Actions #1

Updated by Go MAEDA about 6 years ago

Actions #2

Updated by Sho HASHIMOTO about 6 years ago

Above problem fixed by csv gem 1.0.1.

Actions #3

Updated by Go MAEDA about 6 years ago

Sho HASHIMOTO wrote:

Above problem fixed by csv gem 1.0.1.

Thank you for looking into this issue. Do you think we can fix this issue by changing Gemfile as follows?

Index: Gemfile
===================================================================
--- Gemfile    (revision 17236)
+++ Gemfile    (working copy)
@@ -13,6 +13,7 @@
 gem "roadie", "~> 3.2.1" 
 gem "mimemagic" 
 gem "mail", "~> 2.6.4" 
+gem "csv", "~> 1.0.1" if RUBY_VERSION >= "2.5" 

 gem "nokogiri", "~> 1.8.0" 
 gem "i18n", "~> 0.7.0" 
Actions #4

Updated by Sho HASHIMOTO about 6 years ago

Thank you for looking into this issue. Do you think we can fix this issue by changing Gemfile as follows?

I think so. My patch is not needed any more. :)
I checked unit test only appending below line to Gemfile.local. My Ruby was 2.5.0.

gem 'csv', '1.0.1'
Actions #5

Updated by Go MAEDA almost 6 years ago

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

Committed the fix. Thank you for working on this issue.

Actions #6

Updated by Go MAEDA almost 6 years ago

  • Related to Defect #28689: csv 1.0.2 gem breaks ImportsControllerTest added
Actions #7

Updated by Go MAEDA over 5 years ago

  • Subject changed from Ruby 2.5.0 don't pass csv_test.rb to CsvTest fails due to a regression in Ruby 2.5
Actions

Also available in: Atom PDF