summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-12-20 11:50:32 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-12-20 11:50:32 +0900
commite672494cd737b8fea3a186aeb5c2c17d1a18cb96 (patch)
tree7c10a5af0630284fc69342e9598a3c0176e0b27c /test
parentfac60be324260cd834478fedf934e59b97935dbf (diff)
Merge RubyGems 3.1.2
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem.rb15
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb66
-rw-r--r--test/rubygems/test_gem_installer.rb33
3 files changed, 71 insertions, 43 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index a0debb488c..6d223b7d69 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1917,16 +1917,11 @@ You may need to `gem install -g` to install missing gems
end
def with_bindir_and_exeext(bindir, exeext)
- orig_bindir = RbConfig::CONFIG['bindir']
- orig_exe_ext = RbConfig::CONFIG['EXEEXT']
-
- RbConfig::CONFIG['bindir'] = bindir
- RbConfig::CONFIG['EXEEXT'] = exeext
-
- yield
- ensure
- RbConfig::CONFIG['bindir'] = orig_bindir
- RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
+ bindir(bindir) do
+ exeext(exeext) do
+ yield
+ end
+ end
end
def with_clean_path_to_ruby
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 02171ece9d..c63f7177c7 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -123,6 +123,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_equal "I changed it!\n", File.read(gem_bin_path)
end
+ def test_execute_informs_about_installed_executables
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ out = @ui.output.split "\n"
+
+ exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
+ assert_equal "\t#{default_gem_bin_path}", out.shift
+ assert_equal "\t#{default_bundle_bin_path}", out.shift
+ end
+
def test_env_shebang_flag
gem_bin_path = gem_install 'a'
write_file gem_bin_path do |io|
@@ -133,10 +145,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.options[:env_shebang] = true
@cmd.execute
- gem_exec = sprintf Gem.default_exec_format, 'gem'
- default_gem_bin_path = File.join @install_dir, 'bin', gem_exec
- bundle_exec = sprintf Gem.default_exec_format, 'bundle'
- default_bundle_bin_path = File.join @install_dir, 'bin', bundle_exec
ruby_exec = sprintf Gem.default_exec_format, 'ruby'
if Gem.win_platform?
@@ -212,10 +220,41 @@ class TestGemCommandsSetupCommand < Gem::TestCase
# TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
- # expect to not remove bundler-* direcotyr.
+ # expect to not remove bundler-* directory.
assert_path_exists 'default/gems/bundler-audit-1.0.0'
end
+ def test_install_default_bundler_gem_with_force_flag
+ @cmd.extend FileUtils
+
+ bin_dir = File.join(@gemhome, 'bin')
+ bundle_bin = File.join(bin_dir, 'bundle')
+
+ write_file bundle_bin do |f|
+ f.puts '#!/usr/bin/ruby'
+ f.puts ''
+ f.puts 'echo "hello"'
+ end
+
+ bindir(bin_dir) do
+ @cmd.options[:force] = true
+
+ @cmd.install_default_bundler_gem bin_dir
+
+ bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
+ default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
+ spec = Gem::Specification.load(default_spec_path)
+
+ spec.executables.each do |e|
+ if Gem.win_platform?
+ assert_path_exists File.join(bin_dir, "#{e}.bat")
+ end
+
+ assert_path_exists File.join bin_dir, Gem.default_exec_format % e
+ end
+ end
+ end
+
def test_remove_old_lib_files
lib = File.join @install_dir, 'lib'
lib_rubygems = File.join lib, 'rubygems'
@@ -308,11 +347,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
* Fixed release note display for LANG=C when installing rubygems
* π is tasty
-=== 2.0.2 / 2013-03-06
-
-* Bug fixes:
- * Other bugs fixed
-
EXPECTED
output = @ui.output
@@ -323,4 +357,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@ui.outs.set_encoding @default_external if @default_external
end
+ private
+
+ def default_gem_bin_path
+ gem_exec = sprintf Gem.default_exec_format, 'gem'
+ File.join @install_dir, 'bin', gem_exec
+ end
+
+ def default_bundle_bin_path
+ bundle_exec = sprintf Gem.default_exec_format, 'bundle'
+ File.join @install_dir, 'bin', bundle_exec
+ end
+
end unless Gem.java_platform?
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 7a5fb972a4..731a1ac01d 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -104,32 +104,19 @@ end
def test_check_executable_overwrite_default_bin_dir
installer = setup_base_installer
- if defined?(RUBY_FRAMEWORK_VERSION)
- orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
- Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
- end
- orig_bindir = RbConfig::CONFIG['bindir']
- RbConfig::CONFIG['bindir'] = Gem.bindir
+ bindir(Gem.bindir) do
+ util_conflict_executable false
- util_conflict_executable false
+ ui = Gem::MockGemUi.new "n\n"
+ use_ui ui do
+ e = assert_raises Gem::InstallError do
+ installer.generate_bin
+ end
- ui = Gem::MockGemUi.new "n\n"
- use_ui ui do
- e = assert_raises Gem::InstallError do
- installer.generate_bin
+ conflicted = File.join @gemhome, 'bin', 'executable'
+ assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
+ e.message
end
-
- conflicted = File.join @gemhome, 'bin', 'executable'
- assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
- e.message
- end
- ensure
- Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
- orig_RUBY_FRAMEWORK_VERSION
- if orig_bindir
- RbConfig::CONFIG['bindir'] = orig_bindir
- else
- RbConfig::CONFIG.delete 'bindir'
end
end