2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2008-03-31 18:40:06 -04:00
|
|
|
require 'rubygems/installer'
|
|
|
|
|
|
|
|
class Gem::Installer
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
attr_writer :gem_dir
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :format
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :gem_home
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :env_shebang
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :ignore_dependencies
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :format_executable
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :security_policy
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :spec
|
2011-01-28 18:46:47 -05:00
|
|
|
|
|
|
|
##
|
|
|
|
# Available through requiring rubygems/installer_test_case
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
attr_writer :wrappers
|
|
|
|
end
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
##
|
|
|
|
# A test case for Gem::Installer.
|
|
|
|
|
|
|
|
class Gem::InstallerTestCase < Gem::TestCase
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
@installer_tmp = File.join @tempdir, 'installer'
|
|
|
|
FileUtils.mkdir_p @installer_tmp
|
2011-01-28 18:46:47 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
Gem.use_paths @installer_tmp
|
|
|
|
Gem.ensure_gem_subdirectories @installer_tmp
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
@spec = quick_gem 'a'
|
|
|
|
util_make_exec @spec
|
|
|
|
util_build_gem @spec
|
|
|
|
@gem = @spec.cache_file
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
@user_spec = quick_gem 'b'
|
2011-03-01 04:41:32 -05:00
|
|
|
util_make_exec @user_spec
|
2011-05-31 23:45:05 -04:00
|
|
|
util_build_gem @user_spec
|
|
|
|
@user_gem = @user_spec.cache_file
|
|
|
|
|
|
|
|
Gem.use_paths @gemhome
|
2011-03-01 04:41:32 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
@installer = util_installer @spec, @gemhome
|
|
|
|
@user_installer = util_installer @user_spec, Gem.user_dir, :user
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
Gem.use_paths @gemhome
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2011-03-01 04:41:32 -05:00
|
|
|
def util_gem_bindir spec = @spec
|
2011-05-31 23:45:05 -04:00
|
|
|
# TODO: deprecate
|
|
|
|
spec.bin_dir
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2011-03-01 04:41:32 -05:00
|
|
|
def util_gem_dir spec = @spec
|
2011-05-31 23:45:05 -04:00
|
|
|
# TODO: deprecate
|
|
|
|
spec.gem_dir
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def util_inst_bindir
|
|
|
|
File.join @gemhome, "bin"
|
|
|
|
end
|
|
|
|
|
2011-03-01 04:41:32 -05:00
|
|
|
def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
|
|
|
|
spec.executables = %w[executable]
|
|
|
|
spec.files << 'bin/executable'
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
exec_path = spec.bin_file "executable"
|
|
|
|
write_file exec_path do |io|
|
2011-03-01 04:41:32 -05:00
|
|
|
io.puts shebang
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
bin_path = File.join @tempdir, "bin", "executable"
|
|
|
|
write_file bin_path do |io|
|
2011-03-01 04:41:32 -05:00
|
|
|
io.puts shebang
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic
|
2011-03-01 04:41:32 -05:00
|
|
|
@spec.files << File.join('lib', 'code.rb')
|
2008-03-31 18:40:06 -04:00
|
|
|
@spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
|
|
|
|
|
|
|
|
Dir.chdir @tempdir do
|
|
|
|
FileUtils.mkdir_p 'bin'
|
|
|
|
FileUtils.mkdir_p 'lib'
|
|
|
|
FileUtils.mkdir_p File.join('ext', 'a')
|
|
|
|
File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
|
|
|
|
File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
|
|
|
|
File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
|
|
|
|
f << <<-EOF
|
|
|
|
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
|
|
|
|
use_ui ui do
|
|
|
|
FileUtils.rm @gem
|
2011-05-31 23:45:05 -04:00
|
|
|
|
|
|
|
@gem = Gem::Builder.new(@spec).build
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@installer = Gem::Installer.new @gem
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def util_installer(spec, gem_home, user=false)
|
|
|
|
Gem::Installer.new spec.cache_file, :user_install => user
|
2009-06-09 17:38:59 -04:00
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|