From bf2d4e93b1f053d3fea18890728b2e12cd7fc34b Mon Sep 17 00:00:00 2001 From: usa Date: Sat, 25 Mar 2017 17:35:52 +0000 Subject: merge revision(s) 54785: [Backport #11900] * ruby.c (process_options): convert -e script to the encoding given by a command line option on Windows. assume it is the expected encoding. [ruby-dev:49461] [Bug #11900] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_rubyoptions.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index d3ac0bc0cf..d61569b03f 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -739,6 +739,34 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-e", "puts ARGV", "*.txt"], "", ougai) end end + + def assert_e_script_encoding(str, args = []) + cmds = [ + EnvUtil::LANG_ENVS.inject({}) {|h, k| h[k] = ENV[k]; h}, + *args, + '-e', "s = '#{str}'", + '-e', 'puts s.encoding.name', + '-e', 'puts s.dump', + ] + assert_in_out_err(cmds, "", [str.encoding.name, str.dump], [], + "#{str.encoding}:#{str.dump} #{args.inspect}") + end + + # tested codepages: 437 850 852 855 932 65001 + # Since the codepage is shared all processes per conhost.exe, do + # not chcp, or parallel test may break. + def test_locale_codepage + locale = Encoding.find("locale") + list = %W"\u{c7} \u{452} \u{3066 3059 3068}" + list.each do |s| + assert_e_script_encoding(s, %w[-U]) + end + list.each do |s| + s = s.encode(locale) rescue next + assert_e_script_encoding(s) + assert_e_script_encoding(s, %W[-E#{locale.name}]) + end + end when /cygwin/ def test_command_line_non_ascii assert_separately([{"LC_ALL"=>"ja_JP.SJIS"}, "-", "\u{3042}".encode("SJIS")], <<-"end;") -- cgit v1.2.3