mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/test/unit/ui/console/testrunner.rb: prevent destructive modification to $0.
* test/rubygems/gemutilities.rb (build_rake_in): move from test_gem_ext_rake_builder.rb. * test/rubygems/test_gem_ext_rake_builder.rb: ditto. * test/rubygems/test_gem_installer.rb: override Gem.ruby and ENV["rake"]. * test/rubygems/test_gem_uninstaller.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									807fbd6940
								
							
						
					
					
						commit
						498324c5d3
					
				
					 6 changed files with 95 additions and 43 deletions
				
			
		
							
								
								
									
										16
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,19 @@
 | 
			
		|||
Tue Jul  1 21:32:43 2008  Yusuke Endoh  <mame@tsg.ne.jp>
 | 
			
		||||
 | 
			
		||||
	* lib/test/unit/ui/console/testrunner.rb: prevent destructive
 | 
			
		||||
	  modification to $0.
 | 
			
		||||
 | 
			
		||||
	* test/rubygems/gemutilities.rb (build_rake_in): move from
 | 
			
		||||
	  test_gem_ext_rake_builder.rb.
 | 
			
		||||
 | 
			
		||||
	* test/rubygems/test_gem_ext_rake_builder.rb: ditto.
 | 
			
		||||
 | 
			
		||||
	* test/rubygems/test_gem_installer.rb: override Gem.ruby and
 | 
			
		||||
	  ENV["rake"].
 | 
			
		||||
 | 
			
		||||
	* test/rubygems/test_gem_uninstaller.rb: ditto.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Tue Jul  1 21:13:17 2008  Koichi Sasada  <ko1@atdot.net>
 | 
			
		||||
 | 
			
		||||
	* compile.c, vm.c, insns.def: call FrozenCore.set_postexe method
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,10 +90,8 @@ module Test
 | 
			
		|||
          end
 | 
			
		||||
          
 | 
			
		||||
          def test_started(name)
 | 
			
		||||
            unless defined? $program_name
 | 
			
		||||
              $program_name = $0
 | 
			
		||||
              alias $0 $program_name
 | 
			
		||||
            end
 | 
			
		||||
            $program_name = $0
 | 
			
		||||
            alias $0 $program_name
 | 
			
		||||
            $PROGRAM_NAME += "\0#{name}"
 | 
			
		||||
            output_single(name + ": ", VERBOSE)
 | 
			
		||||
          end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -392,5 +392,50 @@ class RubyGemTestCase < Test::Unit::TestCase
 | 
			
		|||
    self.class.process_based_port
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def build_rake_in
 | 
			
		||||
    gem_ruby = Gem.ruby
 | 
			
		||||
    ruby = @@ruby
 | 
			
		||||
    Gem.module_eval {@ruby = ruby}
 | 
			
		||||
    env_rake = ENV["rake"]
 | 
			
		||||
    ENV["rake"] = @@rake
 | 
			
		||||
    yield @@rake
 | 
			
		||||
  ensure
 | 
			
		||||
    Gem.module_eval {@ruby = gem_ruby}
 | 
			
		||||
    if env_rake
 | 
			
		||||
      ENV["rake"] = env_rake
 | 
			
		||||
    else
 | 
			
		||||
      ENV.delete("rake")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.rubybin
 | 
			
		||||
    if ruby = ENV["RUBY"]
 | 
			
		||||
      return ruby
 | 
			
		||||
    end
 | 
			
		||||
    ruby = "ruby"
 | 
			
		||||
    rubyexe = ruby+".exe"
 | 
			
		||||
    3.times do
 | 
			
		||||
      if File.exist? ruby and File.executable? ruby and !File.directory? ruby
 | 
			
		||||
        return File.expand_path(ruby)
 | 
			
		||||
      end
 | 
			
		||||
      if File.exist? rubyexe and File.executable? rubyexe
 | 
			
		||||
        return File.expand_path(rubyexe)
 | 
			
		||||
      end
 | 
			
		||||
      ruby = File.join("..", ruby)
 | 
			
		||||
    end
 | 
			
		||||
    begin
 | 
			
		||||
      require "rbconfig"
 | 
			
		||||
      File.join(
 | 
			
		||||
        RbConfig::CONFIG["bindir"],
 | 
			
		||||
	RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
 | 
			
		||||
      )
 | 
			
		||||
    rescue LoadError
 | 
			
		||||
      "ruby"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  @@ruby = rubybin
 | 
			
		||||
  @@rake = ENV["rake"] || (@@ruby + " " + File.expand_path("../../../bin/rake", __FILE__))
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,9 +3,6 @@ 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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -16,24 +13,6 @@ 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
 | 
			
		||||
| 
						 | 
				
			
			@ -46,9 +25,11 @@ class TestGemExtRakeBuilder < RubyGemTestCase
 | 
			
		|||
    output = []
 | 
			
		||||
    realdir = nil # HACK /tmp vs. /private/tmp
 | 
			
		||||
 | 
			
		||||
    build_rake_in @ext do
 | 
			
		||||
      realdir = Dir.pwd
 | 
			
		||||
      Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
 | 
			
		||||
    build_rake_in do
 | 
			
		||||
      Dir.chdir @ext do
 | 
			
		||||
        realdir = Dir.pwd
 | 
			
		||||
        Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    expected = [
 | 
			
		||||
| 
						 | 
				
			
			@ -73,8 +54,10 @@ class TestGemExtRakeBuilder < RubyGemTestCase
 | 
			
		|||
    output = []
 | 
			
		||||
 | 
			
		||||
    error = assert_raise Gem::InstallError do
 | 
			
		||||
      build_rake_in @ext do
 | 
			
		||||
        Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
 | 
			
		||||
      build_rake_in do
 | 
			
		||||
        Dir.chdir @ext do
 | 
			
		||||
          Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -529,8 +529,10 @@ load 'my_exec'
 | 
			
		|||
    Dir.mkdir util_inst_bindir
 | 
			
		||||
    util_setup_gem
 | 
			
		||||
 | 
			
		||||
    use_ui @ui do
 | 
			
		||||
      assert_equal @spec, @installer.install
 | 
			
		||||
    build_rake_in do
 | 
			
		||||
      use_ui @ui do
 | 
			
		||||
        assert_equal @spec, @installer.install
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    gemdir = File.join @gemhome, 'gems', @spec.full_name
 | 
			
		||||
| 
						 | 
				
			
			@ -600,8 +602,10 @@ load 'my_exec'
 | 
			
		|||
    util_setup_gem
 | 
			
		||||
    @installer.ignore_dependencies = true
 | 
			
		||||
 | 
			
		||||
    use_ui @ui do
 | 
			
		||||
      assert_equal @spec, @installer.install
 | 
			
		||||
    build_rake_in do
 | 
			
		||||
      use_ui @ui do
 | 
			
		||||
        assert_equal @spec, @installer.install
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    gemdir = File.join @gemhome, 'gems', @spec.full_name
 | 
			
		||||
| 
						 | 
				
			
			@ -646,9 +650,11 @@ load 'my_exec'
 | 
			
		|||
      install_dir = File.join @userhome, '.gem', 'gems', @spec.full_name
 | 
			
		||||
      @spec.executables = ["executable"]
 | 
			
		||||
 | 
			
		||||
      use_ui @ui do
 | 
			
		||||
        util_setup_gem
 | 
			
		||||
        @installer.install
 | 
			
		||||
      build_rake_in do
 | 
			
		||||
        use_ui @ui do
 | 
			
		||||
          util_setup_gem
 | 
			
		||||
          @installer.install
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    
 | 
			
		||||
      assert File.exist?(File.join(install_dir, 'lib', 'code.rb'))
 | 
			
		||||
| 
						 | 
				
			
			@ -663,10 +669,12 @@ load 'my_exec'
 | 
			
		|||
      File.chmod 0755, @userhome
 | 
			
		||||
      File.chmod 0000, util_inst_bindir
 | 
			
		||||
 | 
			
		||||
      use_ui @ui do
 | 
			
		||||
        setup
 | 
			
		||||
        util_setup_gem
 | 
			
		||||
        @installer.install
 | 
			
		||||
      build_rake_in do
 | 
			
		||||
        use_ui @ui do
 | 
			
		||||
          setup
 | 
			
		||||
          util_setup_gem
 | 
			
		||||
          @installer.install
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
      assert File.exist?(File.join(@userhome, '.gem', 'bin', 'executable'))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,8 +10,10 @@ class TestGemUninstaller < GemInstallerTestCase
 | 
			
		|||
    ui = MockGemUi.new
 | 
			
		||||
    util_setup_gem ui
 | 
			
		||||
 | 
			
		||||
    use_ui ui do
 | 
			
		||||
      @installer.install
 | 
			
		||||
    build_rake_in do
 | 
			
		||||
      use_ui ui do
 | 
			
		||||
        @installer.install
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue