From 440714529477663f19a683f2ccee8f568a5481c6 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 20 Dec 2012 03:43:53 +0000 Subject: [PATCH] test_require.rb: clear load path * test/ruby/test_require.rb (test_require_invalid_shared_object), (test_require_too_long_filename, test_require_changed_current_dir), (test_require_not_modified_load_path, test_require_changed_home), (test_require_to_path_redefined_in_load_path), (test_require_to_str_redefined_in_load_path), (assert_require_with_shared_array_modified): clear preset load path so that unexpected files will not get loaded. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_require.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 3d6981d303..2075e09e4f 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -19,6 +19,7 @@ class TestRequire < Test::Unit::TestCase t.close assert_in_out_err([], <<-INPUT, %w(:ok), []) + $:.replace([IO::NULL]) begin require \"#{ t.path }\" rescue LoadError @@ -29,6 +30,7 @@ class TestRequire < Test::Unit::TestCase def test_require_too_long_filename assert_in_out_err(["RUBYOPT"=>nil], <<-INPUT, %w(:ok), []) + $:.replace([IO::NULL]) begin require '#{ "foo/" * 10000 }foo' rescue LoadError @@ -447,6 +449,7 @@ class TestRequire < Test::Unit::TestCase f.puts "p :ok" } assert_in_out_err([], <<-INPUT, %w(:ok), [], bug7158) + $:.replace([IO::NULL]) $: << "." Dir.chdir("a") require "foo" @@ -465,6 +468,7 @@ class TestRequire < Test::Unit::TestCase Dir.chdir(tmp) { open("foo.rb", "w") {} assert_in_out_err([], <<-INPUT, %w(:ok), [], bug7158) + $:.replace([IO::NULL]) a = Object.new def a.to_str "#{tmp}" @@ -486,6 +490,7 @@ class TestRequire < Test::Unit::TestCase Dir.mkdir("a") open(File.join("a", "bar.rb"), "w") {} assert_in_out_err([], <<-INPUT, %w(:ok), [], bug7158) + $:.replace([IO::NULL]) $: << '~' ENV['HOME'] = "#{tmp}" require "foo" @@ -502,6 +507,7 @@ class TestRequire < Test::Unit::TestCase Dir.chdir(tmp) { open("foo.rb", "w") {} assert_in_out_err(["RUBYOPT"=>nil], <<-INPUT, %w(:ok), [], bug7158) + $:.replace([IO::NULL]) a = Object.new def a.to_path "bar" @@ -527,6 +533,7 @@ class TestRequire < Test::Unit::TestCase Dir.chdir(tmp) { open("foo.rb", "w") {} assert_in_out_err(["RUBYOPT"=>nil], <<-INPUT, %w(:ok), [], bug7158) + $:.replace([IO::NULL]) a = Object.new def a.to_str "foo" @@ -554,6 +561,7 @@ class TestRequire < Test::Unit::TestCase Dir.mkdir("a") open(File.join("a", "bar.rb"), "w") {} assert_in_out_err([], <<-INPUT, %w(:ok), [], bug7383) + $:.replace([IO::NULL]) $:.#{add} "#{tmp}" $:.#{add} "#{tmp}/a" require "foo"