* 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
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>
|
Tue Jul 1 21:13:17 2008 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* compile.c, vm.c, insns.def: call FrozenCore.set_postexe method
|
* compile.c, vm.c, insns.def: call FrozenCore.set_postexe method
|
||||||
|
@ -90,10 +90,8 @@ module Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_started(name)
|
def test_started(name)
|
||||||
unless defined? $program_name
|
$program_name = $0
|
||||||
$program_name = $0
|
alias $0 $program_name
|
||||||
alias $0 $program_name
|
|
||||||
end
|
|
||||||
$PROGRAM_NAME += "\0#{name}"
|
$PROGRAM_NAME += "\0#{name}"
|
||||||
output_single(name + ": ", VERBOSE)
|
output_single(name + ": ", VERBOSE)
|
||||||
end
|
end
|
||||||
|
@ -392,5 +392,50 @@ class RubyGemTestCase < Test::Unit::TestCase
|
|||||||
self.class.process_based_port
|
self.class.process_based_port
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
@ -3,9 +3,6 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|||||||
require 'rubygems/ext'
|
require 'rubygems/ext'
|
||||||
|
|
||||||
class TestGemExtRakeBuilder < RubyGemTestCase
|
class TestGemExtRakeBuilder < RubyGemTestCase
|
||||||
@@ruby = ENV["RUBY"]
|
|
||||||
@@rake = ENV["rake"] || (@@ruby + " " + File.expand_path("../../../bin/rake", __FILE__))
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@ -16,24 +13,6 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
|||||||
FileUtils.mkdir_p @dest_path
|
FileUtils.mkdir_p @dest_path
|
||||||
end
|
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
|
def test_class_build
|
||||||
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
|
||||||
mkrf_conf.puts <<-EO_MKRF
|
mkrf_conf.puts <<-EO_MKRF
|
||||||
@ -46,9 +25,11 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
|||||||
output = []
|
output = []
|
||||||
realdir = nil # HACK /tmp vs. /private/tmp
|
realdir = nil # HACK /tmp vs. /private/tmp
|
||||||
|
|
||||||
build_rake_in @ext do
|
build_rake_in do
|
||||||
realdir = Dir.pwd
|
Dir.chdir @ext do
|
||||||
Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
|
realdir = Dir.pwd
|
||||||
|
Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
@ -73,8 +54,10 @@ class TestGemExtRakeBuilder < RubyGemTestCase
|
|||||||
output = []
|
output = []
|
||||||
|
|
||||||
error = assert_raise Gem::InstallError do
|
error = assert_raise Gem::InstallError do
|
||||||
build_rake_in @ext do
|
build_rake_in do
|
||||||
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
|
Dir.chdir @ext do
|
||||||
|
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -529,8 +529,10 @@ load 'my_exec'
|
|||||||
Dir.mkdir util_inst_bindir
|
Dir.mkdir util_inst_bindir
|
||||||
util_setup_gem
|
util_setup_gem
|
||||||
|
|
||||||
use_ui @ui do
|
build_rake_in do
|
||||||
assert_equal @spec, @installer.install
|
use_ui @ui do
|
||||||
|
assert_equal @spec, @installer.install
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
gemdir = File.join @gemhome, 'gems', @spec.full_name
|
gemdir = File.join @gemhome, 'gems', @spec.full_name
|
||||||
@ -600,8 +602,10 @@ load 'my_exec'
|
|||||||
util_setup_gem
|
util_setup_gem
|
||||||
@installer.ignore_dependencies = true
|
@installer.ignore_dependencies = true
|
||||||
|
|
||||||
use_ui @ui do
|
build_rake_in do
|
||||||
assert_equal @spec, @installer.install
|
use_ui @ui do
|
||||||
|
assert_equal @spec, @installer.install
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
gemdir = File.join @gemhome, 'gems', @spec.full_name
|
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
|
install_dir = File.join @userhome, '.gem', 'gems', @spec.full_name
|
||||||
@spec.executables = ["executable"]
|
@spec.executables = ["executable"]
|
||||||
|
|
||||||
use_ui @ui do
|
build_rake_in do
|
||||||
util_setup_gem
|
use_ui @ui do
|
||||||
@installer.install
|
util_setup_gem
|
||||||
|
@installer.install
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert File.exist?(File.join(install_dir, 'lib', 'code.rb'))
|
assert File.exist?(File.join(install_dir, 'lib', 'code.rb'))
|
||||||
@ -663,10 +669,12 @@ load 'my_exec'
|
|||||||
File.chmod 0755, @userhome
|
File.chmod 0755, @userhome
|
||||||
File.chmod 0000, util_inst_bindir
|
File.chmod 0000, util_inst_bindir
|
||||||
|
|
||||||
use_ui @ui do
|
build_rake_in do
|
||||||
setup
|
use_ui @ui do
|
||||||
util_setup_gem
|
setup
|
||||||
@installer.install
|
util_setup_gem
|
||||||
|
@installer.install
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert File.exist?(File.join(@userhome, '.gem', 'bin', 'executable'))
|
assert File.exist?(File.join(@userhome, '.gem', 'bin', 'executable'))
|
||||||
|
@ -10,8 +10,10 @@ class TestGemUninstaller < GemInstallerTestCase
|
|||||||
ui = MockGemUi.new
|
ui = MockGemUi.new
|
||||||
util_setup_gem ui
|
util_setup_gem ui
|
||||||
|
|
||||||
use_ui ui do
|
build_rake_in do
|
||||||
@installer.install
|
use_ui ui do
|
||||||
|
@installer.install
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user