ruby-changes:61763
From: Yusuke <ko1@a...>
Date: Thu, 18 Jun 2020 09:39:52 +0900 (JST)
Subject: [ruby-changes:61763] bed17974a1 (master): test/webrick/test_filehandler.rb: no `.encode("filesystem")` if US-ASCII
https://git.ruby-lang.org/ruby.git/commit/?id=bed17974a1 From bed17974a1563852c3d1d2b7b24033ed0beaa33e Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Thu, 18 Jun 2020 09:37:54 +0900 Subject: test/webrick/test_filehandler.rb: no `.encode("filesystem")` if US-ASCII http://ci.rvm.jp/logfiles/brlog.trunk-theap-asserts.20200618-002305 ``` I, [2020-06-18T00:28:11.661066 #31625] INFO -- : 1) Failure: I, [2020-06-18T00:28:11.661157 #31625] INFO -- : WEBrick::TestFileHandler#test_cjk_in_path [/tmp/ruby/v3/src/trunk-theap-asserts/test/webrick/utils.rb:72]: I, [2020-06-18T00:28:11.661216 #31625] INFO -- : exceptions on 1 threads: I, [2020-06-18T00:28:11.661269 #31625] INFO -- : U+3042 from UTF-8 to US-ASCII ``` diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index ffd10cc..1d2895f 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -294,8 +294,13 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/webrick/test_filehandler.rb#L294 config = { :DocumentRoot => dir } TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) - filesystem_path = "\u3042".encode("filesystem").bytes.map {|b| "%%%X" % b }.join - req = Net::HTTP::Get.new("/#{ filesystem_path }.txt") + case enc = Encoding.find('filesystem') + when Encoding::US_ASCII, Encoding::ASCII_8BIT + filesystem_path = "\u3042" + else + filesystem_path = "\u3042".encode("filesystem") + end + req = Net::HTTP::Get.new("/#{ filesystem_path.bytes.map {|b| "%%%X" % b }.join }.txt") http.request(req){|res| assert_equal("200", res.code, log.call + "\nFilesystem encoding is #{Encoding.find('filesystem')}") } end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/