diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem_ext_rake_builder.rb | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb index cf8e2a6d6b..6bc3ea08eb 100644 --- a/test/rubygems/test_gem_ext_rake_builder.rb +++ b/test/rubygems/test_gem_ext_rake_builder.rb @@ -3,6 +3,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require 'rubygems/ext' class TestGemExtRakeBuilder < RubyGemTestCase + @@ruby = ENV["RUBY"] + @@rake = ENV["rake"] || (@@ruby + " " + File.expand_path("../../../bin/rake", __FILE__)) def setup super @@ -14,6 +16,24 @@ class TestGemExtRakeBuilder < RubyGemTestCase FileUtils.mkdir_p @dest_path end + def build_rake_in dir + gem_ruby = Gem.ruby + ruby = @@ruby + Gem.module_eval {@ruby = ruby} + env_rake = ENV["rake"] + ENV["rake"] = @@rake + Dir.chdir dir do + yield @@rake + end + ensure + Gem.module_eval {@ruby = gem_ruby} + if env_rake + ENV["rake"] = env_rake + else + ENV.delete("rake") + end + end + def test_class_build File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf| mkrf_conf.puts <<-EO_MKRF @@ -26,15 +46,15 @@ class TestGemExtRakeBuilder < RubyGemTestCase output = [] realdir = nil # HACK /tmp vs. /private/tmp - Dir.chdir @ext do + build_rake_in @ext do realdir = Dir.pwd Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output end expected = [ - "#{Gem.ruby} mkrf_conf.rb", + "#{@@ruby} mkrf_conf.rb", "", - "#{ENV['rake'] || 'rake'} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}", + "#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}", "(in #{realdir})\n" ] @@ -53,7 +73,7 @@ class TestGemExtRakeBuilder < RubyGemTestCase output = [] error = assert_raise Gem::InstallError do - Dir.chdir @ext do + build_rake_in @ext do Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output end end @@ -61,9 +81,9 @@ class TestGemExtRakeBuilder < RubyGemTestCase expected = <<-EOF.strip rake failed: -#{Gem.ruby} mkrf_conf.rb +#{@@ruby} mkrf_conf.rb -#{ENV['rake'] || 'rake'} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path} +#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path} EOF assert_equal expected, error.message.split("\n")[0..4].join("\n") |