Bug #6650

Fixing win32ole test errors

Added by Boško Ivanišević about 3 years ago. Updated almost 3 years ago.

[ruby-core:<unknown>]
Status:Closed
Priority:Normal
Assignee:Masaki Suketa
ruby -v:ruby 2.0.0dev (2012-06-25 trunk 36180) [i386-mingw32] Backport:

Description

Since FileSystemObject is limited only to ANSI and UTF-16LE encoding tests shouldn't try to use other encodings since they will certainly fail. Instead UTF-16 encoding should be used to check whether writing/reading to/from FSO is properly handled. Attached is a patch that fixes this.

0001-FileSystemObject-does-not-support-UTF-8.patch Magnifier (1.74 KB) Boško Ivanišević, 06/26/2012 10:43 PM

0001-Use-UTF-16-String-instead-of-UTF-8.patch Magnifier (1.33 KB) Hiroshi Shirosaki, 06/29/2012 09:39 PM

Associated revisions

Revision 36246
Added by Luis Lavena about 3 years ago

  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by bosko (Bosko Ivanisevic) [ruby-trunk - Bug #6650]

Revision 36246
Added by Luis Lavena about 3 years ago

  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by bosko (Bosko Ivanisevic) [ruby-trunk - Bug #6650]

Revision 36306
Added by Masaki Suketa about 3 years ago

  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by h.shirosaki (Hiroshi Shirosaki) [ruby-trunk - Bug #6650]

Revision 36306
Added by Masaki Suketa about 3 years ago

  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by h.shirosaki (Hiroshi Shirosaki) [ruby-trunk - Bug #6650]

History

#1 Updated by Luis Lavena about 3 years ago

  • Target version set to 2.0.0
  • Status changed from Open to Assigned

#2 Updated by Luis Lavena about 3 years ago

  • % Done changed from 0 to 100
  • Status changed from Assigned to Closed

This issue was solved with changeset r36246.
Boško, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by bosko (Bosko Ivanisevic) [ruby-trunk - Bug #6650]

#3 Updated by Masaki Suketa about 3 years ago

  • % Done changed from 100 to 0

I received the following error.

test_s_codepage_changed(TestWin32OLE) [C:/cygwin/home/svn/ruby/test/win32ole/test_win32ole.rb:363]:
<"\xE3\x81\x82"> expected but was
<"\xE3\x81\x81E">.

Finished tests in 53.506664s, 4.1303 tests/s, 12.0359 assertions/s.
221 tests, 644 assertions, 1 failures, 0 errors, 0 skips

ruby -v: ruby 2.0.0dev (2012-06-28 trunk 36246) [i386-mswin32_100]

#4 Updated by Luis Lavena about 3 years ago

  • Status changed from Closed to Feedback

suke,

Can you tell us a bit more about WIN32OLE.locale and WIN32OLE.codepage prior running the tests? what is the default locale (chcp)?

These test work under WIN32OLE.codepage 1252 and 65001, so I'm wondering why they are not in your case.

#5 Updated by Hiroshi Shirosaki about 3 years ago

I had same failure on Win7 with chcp 932(default), 1252 and 65001. I guess it depends on Windows system default encoding.
If I change the string from UTF-8 to UTF-16LE, the test works fine for me.
UTF-16LE or ASCII String might be better. I attached the patch.

#6 Updated by Luis Lavena about 3 years ago

h.shirosaki (Hiroshi Shirosaki) wrote:

I had same failure on Win7 with chcp 932(default), 1252 and 65001. I guess it depends on Windows system default encoding.
If I change the string from UTF-8 to UTF-16LE, the test works fine for me.
UTF-16LE or ASCII String might be better. I attached the patch.

Hiroshi, I don't fully follow the rationale in the patch.

You're encoding the string first as UTF-16LE and then force encoding as UTF-16 when sending it to FSO.

AFAIK FSO Only understands ANSI and UTF-16LE.

Also, by doing force_encoding, you're changing test_str to the new encoding and not preserving the original.

I couldn't find WIN32OLE in the list of maintainers, but will be great to hear his comments.

#7 Updated by Hiroshi Shirosaki about 3 years ago

You're encoding the string first as UTF-16LE and then force encoding as UTF-16 when sending it to FSO.

AFAIK FSO Only understands ANSI and UTF-16LE.

Also, by doing force_encoding, you're changing test_str to the new encoding and not preserving the original.

I did force_encoding("UTF-16") because FSO doesn't allow UTF-16LE encoding and an error occurs. Bosko's patch also uses UTF-16 instead of UTF-16LE. force_encoding doesn't change binary representation of test_str.

#8 Updated by Luis Lavena about 3 years ago

  • Assignee changed from Luis Lavena to Masaki Suketa

Masaki,

Can you confirm tests pass after applying Hiroshi's patch?

Thank you.

#9 Updated by Luis Lavena about 3 years ago

Masaki Suketa,

Can you confirm patch from Hiroshi fix the error for you?

#10 Updated by Masaki Suketa about 3 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36306.
Boško, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/win32ole/test_win32ole.rb (test_s_codepage_changed): FileSystemObject only supports ANSI or UTF-16LE encoding. Patch by h.shirosaki (Hiroshi Shirosaki) [ruby-trunk - Bug #6650]

#11 Updated by Masaki Suketa about 3 years ago

On Sat, Jun 30, 2012 at 11:24:03PM +0900, luislavena (Luis Lavena) wrote:

Can you confirm tests pass after applying Hiroshi's patch?

Sorry for being too late to reply.
I confirmed Hiroshi's patch works fine.

Best Regards,
Masaki Suketa

Also available in: Atom PDF