diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
commit | 9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch) | |
tree | c3cb423d701f7049ba9382de052e2a937cd1302d /lib/rubygems/installer_test_case.rb | |
parent | 3f606b7063fc7a8b191556365ad343a314719a8d (diff) | |
download | ruby-9694bb8cac12969300692dac5a1cf7aa4e3a46cd.tar.gz |
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto.
* common.mk (prelude): Updated for RubyGems 2.0 source rearrangement.
* tool/change_maker.rb: Allow invalid UTF-8 characters in source
files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/installer_test_case.rb')
-rw-r--r-- | lib/rubygems/installer_test_case.rb | 90 |
1 files changed, 71 insertions, 19 deletions
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb index 96a5156995..62a468a8a2 100644 --- a/lib/rubygems/installer_test_case.rb +++ b/lib/rubygems/installer_test_case.rb @@ -6,11 +6,26 @@ class Gem::Installer ## # Available through requiring rubygems/installer_test_case + attr_writer :bin_dir + + ## + # Available through requiring rubygems/installer_test_case + + attr_writer :build_args + + ## + # Available through requiring rubygems/installer_test_case + attr_writer :gem_dir ## # Available through requiring rubygems/installer_test_case + attr_writer :force + + ## + # Available through requiring rubygems/installer_test_case + attr_writer :format ## @@ -54,47 +69,68 @@ end class Gem::InstallerTestCase < Gem::TestCase + ## + # Creates the following instance variables: + # + # @spec:: + # a spec named 'a', intended for regular installs + # @user_spec:: + # a spec named 'b', intended for user installs + + # @gem:: + # the path to a built gem from @spec + # @user_spec:: + # the path to a built gem from @user_spec + # + # @installer:: + # a Gem::Installer for the @spec that installs into @gemhome + # @user_installer:: + # a Gem::Installer for the @user_spec that installs into Gem.user_dir + def setup super - @installer_tmp = File.join @tempdir, 'installer' - FileUtils.mkdir_p @installer_tmp + @spec = quick_gem 'a' do |spec| + util_make_exec spec + end - Gem.use_paths @installer_tmp - Gem.ensure_gem_subdirectories @installer_tmp + @user_spec = quick_gem 'b' do |spec| + util_make_exec spec + end - @spec = quick_gem 'a' - util_make_exec @spec util_build_gem @spec - @gem = @spec.cache_file - - @user_spec = quick_gem 'b' - util_make_exec @user_spec util_build_gem @user_spec - @user_gem = @user_spec.cache_file - Gem.use_paths @gemhome + @gem = @spec.cache_file + @user_gem = @user_spec.cache_file @installer = util_installer @spec, @gemhome @user_installer = util_installer @user_spec, Gem.user_dir, :user - - Gem.use_paths @gemhome end - def util_gem_bindir spec = @spec + def util_gem_bindir spec = @spec # :nodoc: # TODO: deprecate spec.bin_dir end - def util_gem_dir spec = @spec + def util_gem_dir spec = @spec # :nodoc: # TODO: deprecate spec.gem_dir end + ## + # The path where installed executables live + def util_inst_bindir File.join @gemhome, "bin" end + ## + # Adds an executable named "executable" to +spec+ with the given +shebang+. + # + # The executable is also written to the bin dir in @tmpdir and the installed + # gem directory for +spec+. + def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby") spec.executables = %w[executable] spec.files << 'bin/executable' @@ -110,6 +146,14 @@ class Gem::InstallerTestCase < Gem::TestCase end end + ## + # Builds the @spec gem and returns an installer for it. The built gem + # includes: + # + # bin/executable + # lib/code.rb + # ext/a/mkrf_conf.rb + def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic @spec.files << File.join('lib', 'code.rb') @spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb') @@ -129,16 +173,24 @@ class Gem::InstallerTestCase < Gem::TestCase end use_ui ui do - FileUtils.rm @gem + FileUtils.rm_f @gem - @gem = Gem::Builder.new(@spec).build + @gem = Gem::Package.build @spec end end @installer = Gem::Installer.new @gem end + ## + # Creates an installer for +spec+ that will install into +gem_home+. If + # +user+ is true a user-install will be performed. + def util_installer(spec, gem_home, user=false) - Gem::Installer.new spec.cache_file, :user_install => user + Gem::Installer.new(spec.cache_file, + :install_dir => gem_home, + :user_install => user) end + end + |