Bug #7076

TestUnicodeEscape#test_basic failure on Windows

Added by Hiroshi Shirosaki over 1 year ago. Updated over 1 year ago.

[ruby-core:47709]
Status:Closed
Priority:Normal
Assignee:-
Category:test
Target version:-
ruby -v:ruby 2.0.0dev (2012-09-27 trunk 37040) [i386-mingw32] Backport:

Description

=begin
This was originally reported at rubyinstaller-list by Jon.

With chcp 437, TestUnicodeEscape#test_basic fails with invalid byte sequence in UTF-8.

http://pastie.org/4688083

I got the following test failure with chcp 437 on Windows 7.

1) Failure:
testbasic(TestUnicodeEscape) [c:/Users/hiroshi/work/ruby/test/ruby/testunicode_escape.rb:50]:
Expected /"?\u00FC\1$/ to match "\"??\"\n".

echo command on Windows seems not to work properly against non-ascii characters with all code page.

I suggest a patch to use ruby instead of echo.
This patch works fine with chcp 437, 1252 and 65001. Jon also confirmed this.

diff --git a/test/ruby/testunicodeescape.rb b/test/ruby/testunicodeescape.rb
index 088f81c..2c437d9 100644
--- a/test/ruby/testunicodeescape.rb
+++ b/test/ruby/testunicodeescape.rb
@@ -1,6 +1,7 @@
# -- coding: utf-8 --

require 'test/unit'
+require_relative 'envutil'

class TestUnicodeEscape < Test::Unit::TestCase
def testbasic
@@ -47,7 +48,7 @@ EOS
# \u in %x strings
assert
match(/"?A\1$/, echo "\u0041") #"
assertmatch(/"?A\1$/, %x{echo "\u0041"}) #"
- assert
match(/"?ü\1$/, echo "\u{FC}".forceencoding("utf-8")) #"
+ assert
match(/"?ü\1$/, #{EnvUtil.rubybin} -e "puts \\"\u{FC}\\"".force_encoding("utf-8")) #"

  # \u in quoted symbols
  assert_equal(:A, :"\u0041")=end

Associated revisions

Revision 37050
Added by shirosaki over 1 year ago

testunicodeescape.rb: fix test for Windows

  • test/ruby/testunicodeescape.rb (TestUnicodeEscape#test_basic): echo command doesn't work properly against non-ascii character on Windows with chcp 437. Instead we use ruby. [Bug #7076]

Revision 37051
Added by shirosaki over 1 year ago

  • test/ruby/testunicodeescape.rb (TestUnicodeEscape#test_basic): Use ruby only on Windows since the test fails on Unix with LANG=C. [Bug #7076]

History

#1 Updated by Usaku NAKAMURA over 1 year ago

Hello,

In message " [ruby-trunk - Bug #7076][Open] TestUnicodeEscape#test_basic failure on Windows"
on Sep.27,2012 21:44:25, h.shirosaki@gmail.com wrote:

This patch works fine with chcp 437, 1252 and 65001. Jon also confirmed this.

So, commit it, please.

Generally, you can commit a patch by judgment of you, as long as
it does not change the specification.
If it is change of tests like this time, please do not hesitate to do.

Regards,
--
U.Nakamura usa@garbagecollect.jp

#2 Updated by Anonymous over 1 year ago

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

This issue was solved with changeset r37050.
Hiroshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


testunicodeescape.rb: fix test for Windows

  • test/ruby/testunicodeescape.rb (TestUnicodeEscape#test_basic): echo command doesn't work properly against non-ascii character on Windows with chcp 437. Instead we use ruby. [Bug #7076]

#3 Updated by Hiroshi Shirosaki over 1 year ago

On Fri, Sep 28, 2012 at 9:49 AM, U.Nakamura usa@garbagecollect.jp wrote:

Hello,

In message " [ruby-trunk - Bug #7076][Open] TestUnicodeEscape#test_basic failure on Windows"
on Sep.27,2012 21:44:25, h.shirosaki@gmail.com wrote:

This patch works fine with chcp 437, 1252 and 65001. Jon also confirmed this.

So, commit it, please.

Generally, you can commit a patch by judgment of you, as long as
it does not change the specification.
If it is change of tests like this time, please do not hesitate to do.

Hello,

Thank you for comments. The patch had a problem, but I think it was fixed.

And I have other patches for test issues which I see on my local. So
committed those.
With those patches test-all results seems fine even on Windows XP with
gcc version 4.7.2 rubenvb build.

--
Hiroshi Shirosaki

Also available in: Atom PDF