summaryrefslogtreecommitdiff
path: root/test/webrick/test_filehandler.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-06-18 09:37:54 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-06-18 09:37:54 +0900
commitbed17974a1563852c3d1d2b7b24033ed0beaa33e (patch)
treef799cae0987de704606695a9e57881e6c0301fee /test/webrick/test_filehandler.rb
parent35a67418160ebde3901c1a6f1413a950a867514f (diff)
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 ```
Diffstat (limited to 'test/webrick/test_filehandler.rb')
-rw-r--r--test/webrick/test_filehandler.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
index ffd10cc529..1d2895f8ca 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -294,8 +294,13 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
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