summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 15:14:51 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 15:14:51 +0000
commit88d0a18c9fa3cfce8db9ee3fadc0cc15ee5730fe (patch)
tree21f5468da61250046ebd723248501792059418f2 /test
parentc1ca05af16a960a2431cf7afbbae9c034147899a (diff)
merge revision(s) 40135,40148,40173: [Backport #8165]
* load.c (features_index_add): use rb_str_subseq() to specify C string position properly to fix require non ascii path. [ruby-core:53733] [Bug #8165] * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): a test for the above. * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): fix load path for encoding to run the test as stand-alone. * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): RUBY_PLATFORM should escape as Regexp, because RUBY_PLATFORM may contain '.'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_require.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index f6e75a8eaf..c9326380e6 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -58,6 +58,29 @@ class TestRequire < Test::Unit::TestCase
end
end
+ def test_require_nonascii_path
+ bug8165 = '[ruby-core:53733] [Bug #8165]'
+ Dir.mktmpdir {|tmp|
+ encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? 'filesystem' : 'UTF-8'
+ dir = "\u3042" * 5
+ begin
+ require_path = File.join(tmp, dir, 'foo.rb').encode(encoding)
+ rescue
+ skip "cannot convert path encoding to #{encoding}"
+ end
+ Dir.mkdir(File.dirname(require_path))
+ open(require_path, "wb") {}
+ assert_in_out_err([], <<-INPUT, %w(:ok), [], bug8165)
+ # coding: #{encoding}
+ # leave paths for require encoding objects
+ enc_path = Regexp.new(Regexp.escape(RUBY_PLATFORM))
+ $:.replace([IO::NULL] + $:.reject {|path| enc_path !~ path})
+ p :ok if require '#{require_path}'
+ p :ng if require '#{require_path}'
+ INPUT
+ }
+ end
+
def test_require_path_home_1
env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"]
pathname_too_long = /pathname too long \(ignored\).*\(LoadError\)/m