summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-19 21:23:04 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-19 21:23:04 +0000
commit64847a9cfe467b808ca5e8148dfa85a059198963 (patch)
treeb21ca4404f92f1fe269347a8d624cf188e7fbc97 /test
parentdf2762fb1aaa82577b4e3e8df67cc56b7aefdfb8 (diff)
Importing rubygems @ c2d4131: Deal with platforms that have DLEXT2 == nil. Fixes RF#28867
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/gemutilities.rb7
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb8
-rw-r--r--test/rubygems/test_gem_installer.rb108
3 files changed, 113 insertions, 10 deletions
diff --git a/test/rubygems/gemutilities.rb b/test/rubygems/gemutilities.rb
index fc27d6077c..9c94a128d0 100644
--- a/test/rubygems/gemutilities.rb
+++ b/test/rubygems/gemutilities.rb
@@ -130,11 +130,17 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@public_cert = File.expand_path File.join(File.dirname(__FILE__),
'public_cert.pem')
+ Gem.post_build_hooks.clear
Gem.post_install_hooks.clear
Gem.post_uninstall_hooks.clear
Gem.pre_install_hooks.clear
Gem.pre_uninstall_hooks.clear
+ Gem.post_build do |installer|
+ @post_build_hook_arg = installer
+ true
+ end
+
Gem.post_install do |installer|
@post_install_hook_arg = installer
end
@@ -145,6 +151,7 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.pre_install do |installer|
@pre_install_hook_arg = installer
+ true
end
Gem.pre_uninstall do |uninstaller|
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 718a0709dc..b747d08795 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -90,7 +90,9 @@ class TestGemCommandsSourcesCommand < RubyGemTestCase
util_setup_spec_fetcher
use_ui @ui do
- @cmd.execute
+ assert_raises MockGemUi::TermError do
+ @cmd.execute
+ end
end
expected = <<-EOF
@@ -108,7 +110,9 @@ Error fetching http://beta-gems.example.com:
util_setup_spec_fetcher
use_ui @ui do
- @cmd.execute
+ assert_raises MockGemUi::TermError do
+ @cmd.execute
+ end
end
assert_equal [@gem_repo], Gem.sources
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 3e329a2967..c77de792f3 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -521,15 +521,27 @@ load Gem.bin_path('a', 'my_exec', version)
def test_install
Dir.mkdir util_inst_bindir
util_setup_gem
+ util_clear_gems
+ gemdir = File.join @gemhome, 'gems', @spec.full_name
cache_file = File.join @gemhome, 'cache', @spec.file_name
+ stub_exe = File.join @gemhome, 'bin', 'executable'
+ rakefile = File.join gemdir, 'ext', 'a', 'Rakefile'
Gem.pre_install do |installer|
- refute File.exist?(cache_file), 'cache file should not exist yet'
+ refute File.exist?(cache_file), 'cache file must not exist yet'
+ true
+ end
+
+ Gem.post_build do |installer|
+ assert File.exist?(gemdir), 'gem install dir must exist'
+ assert File.exist?(rakefile), 'gem executable must exist'
+ refute File.exist?(stub_exe), 'gem executable must not exist'
+ true
end
Gem.post_install do |installer|
- assert File.exist?(cache_file), 'cache file should exist'
+ assert File.exist?(cache_file), 'cache file must exist'
end
build_rake_in do
@@ -538,25 +550,27 @@ load Gem.bin_path('a', 'my_exec', version)
end
end
- gemdir = File.join @gemhome, 'gems', @spec.full_name
- assert File.exist?(gemdir)
+ assert File.exist? gemdir
+ assert File.exist?(stub_exe), 'gem executable must exist'
+
+ exe = File.join gemdir, 'bin', 'executable'
+ assert File.exist? exe
- exe = File.join(gemdir, 'bin', 'executable')
- assert File.exist?(exe)
exe_mode = File.stat(exe).mode & 0111
assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
assert File.exist?(File.join(gemdir, 'lib', 'code.rb'))
- assert File.exist?(File.join(gemdir, 'ext', 'a', 'Rakefile'))
+ assert File.exist? rakefile
spec_file = File.join(@gemhome, 'specifications', @spec.spec_name)
assert_equal spec_file, @spec.loaded_from
assert File.exist?(spec_file)
- assert_same @installer, @pre_install_hook_arg
+ assert_same @installer, @post_build_hook_arg
assert_same @installer, @post_install_hook_arg
+ assert_same @installer, @pre_install_hook_arg
end
def test_install_bad_gem
@@ -669,6 +683,84 @@ load Gem.bin_path('a', 'my_exec', version)
assert File.exist?(File.join(@gemhome, 'specifications', @spec.spec_name))
end
+ def test_install_post_build_false
+ util_clear_gems
+
+ Gem.post_build do
+ false
+ end
+
+ use_ui @ui do
+ e = assert_raises Gem::InstallError do
+ @installer.install
+ end
+
+ location = "#{__FILE__}:#{__LINE__ - 9}"
+
+ assert_equal "post-build hook at #{location} failed for a-2", e.message
+ end
+
+ spec_file = File.join @gemhome, 'specifications', @spec.spec_name
+ refute File.exist? spec_file
+
+ gem_dir = File.join @gemhome, 'gems', @spec.full_name
+ refute File.exist? gem_dir
+ end
+
+ def test_install_post_build_nil
+ util_clear_gems
+
+ Gem.post_build do
+ nil
+ end
+
+ use_ui @ui do
+ @installer.install
+ end
+
+ spec_file = File.join @gemhome, 'specifications', @spec.spec_name
+ assert File.exist? spec_file
+
+ gem_dir = File.join @gemhome, 'gems', @spec.full_name
+ assert File.exist? gem_dir
+ end
+
+ def test_install_pre_install_false
+ util_clear_gems
+
+ Gem.pre_install do
+ false
+ end
+
+ use_ui @ui do
+ e = assert_raises Gem::InstallError do
+ @installer.install
+ end
+
+ location = "#{__FILE__}:#{__LINE__ - 9}"
+
+ assert_equal "pre-install hook at #{location} failed for a-2", e.message
+ end
+
+ spec_file = File.join @gemhome, 'specifications', @spec.spec_name
+ refute File.exist? spec_file
+ end
+
+ def test_install_pre_install_nil
+ util_clear_gems
+
+ Gem.pre_install do
+ nil
+ end
+
+ use_ui @ui do
+ @installer.install
+ end
+
+ spec_file = File.join @gemhome, 'specifications', @spec.spec_name
+ assert File.exist? spec_file
+ end
+
def test_install_with_message
@spec.post_install_message = 'I am a shiny gem!'