diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_require.rb | 2 | ||||
| -rw-r--r-- | test/ruby/test_rubyoptions.rb | 33 |
2 files changed, 13 insertions, 22 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 0067a49700..eed8e97da8 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -54,7 +54,7 @@ class TestRequire < Test::Unit::TestCase end; begin - assert_in_out_err(["-S", "-w", "foo/" * 1024 + "foo"], "") do |r, e| + assert_in_out_err(["-S", "-w", (["foo"] * 1025).join("_")], "") do |r, e| assert_equal([], r) assert_operator(2, :<=, e.size) assert_match(/warning: openpath: pathname too long \(ignored\)/, e.first) diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index cd2dd5d3ff..4a31f91b4a 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -446,37 +446,28 @@ class TestRubyOptions < Test::Unit::TestCase def test_search rubypath_orig = ENV['RUBYPATH'] path_orig = ENV['PATH'] + libpath = (path_orig if path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH') - Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) {|t| - t.puts "p 1" - t.close - - @verbose = $VERBOSE - $VERBOSE = nil + Dir.mktmpdir("test_ruby_test_rubyoption") do |path| + name = "test_rubyoption.rb" + parent, dir = File.split(path) + File.write("#{path}/#{name}", "p 1") + load_error = %r[#{Regexp.quote dir}/#{Regexp.quote name} \(LoadError\)] - path, name = File.split(t.path) - - ENV['PATH'] = (path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH') ? - [path, path_orig].join(File::PATH_SEPARATOR) : path + ENV['PATH'] = [path, *libpath].join(File::PATH_SEPARATOR) assert_in_out_err(%w(-S) + [name], "", %w(1), []) + ENV['PATH'] = [parent, *libpath].join(File::PATH_SEPARATOR) + assert_in_out_err(%W(-S) + ["#{dir}/#{name}"], "", [], load_error) ENV['PATH'] = path_orig ENV['RUBYPATH'] = path assert_in_out_err(%w(-S) + [name], "", %w(1), []) - } - - ensure - if rubypath_orig + ENV['RUBYPATH'] = parent + assert_in_out_err(%w(-S) + ["#{dir}/#{name}"], "", [], load_error) + ensure ENV['RUBYPATH'] = rubypath_orig - else - ENV.delete('RUBYPATH') - end - if path_orig ENV['PATH'] = path_orig - else - ENV.delete('PATH') end - $VERBOSE = @verbose end def test_shebang |
