From ef5b8fe12f2d1c4a24c71c7965b7e7184ad613d6 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Feb 2015 08:37:27 +0000 Subject: dir.c: preserve encoding * dir.c (sys_enc_warning_in): preserve encoding of path name in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_dir_m17n.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test') diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index 0547f2e62e..325b1571c9 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -303,6 +303,50 @@ class TestDir_M17N < Test::Unit::TestCase } end + def with_enc_path + with_tmpdir do |d| + names = %W"\u{391 392 393 394 395} \u{3042 3044 3046 3048 304a}" + names.each do |dir| + Dir.mkdir(dir) rescue next + begin + yield(dir) + ensure + File.chmod(0700, dir) + end + end + end + end + + def test_glob_warning_opendir + with_enc_path do |dir| + open("#{dir}/x", "w") {} + File.chmod(0300, dir) + assert_warning(/#{dir}/) do + Dir.glob("#{dir}/*") + end + end + end + + def test_glob_warning_match_all + with_enc_path do |dir| + open("#{dir}/x", "w") {} + File.chmod(0000, dir) + assert_warning(/#{dir}/) do + Dir.glob("#{dir}/x") + end + end + end + + def test_glob_warning_match_dir + with_enc_path do |dir| + Dir.mkdir("#{dir}/x") + File.chmod(0000, dir) + assert_warning(/#{dir}/) do + Dir.glob("#{dir}/x/") + end + end + end + def test_entries_compose bug7267 = '[ruby-core:48745] [Bug #7267]' -- cgit v1.2.3