[前][次][番号順一覧][スレッド一覧]

ruby-changes:69603

From: David <ko1@a...>
Date: Fri, 5 Nov 2021 23:21:09 +0900 (JST)
Subject: [ruby-changes:69603] e60c1f7556 (master): [rubygems/rubygems] Refactor setup tests to not always pass `--prefix`

https://git.ruby-lang.org/ruby.git/commit/?id=e60c1f7556

From e60c1f7556878c9e65a6adad537f29c07aea64ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 4 Nov 2021 20:20:47 +0100
Subject: [rubygems/rubygems] Refactor setup tests to not always pass
 `--prefix`

Standard usage should be tested by default. I will add a test for
`--prefix` once I fix that option since it's not working correctly at
the moment.

https://github.com/rubygems/rubygems/commit/50a7e34586
---
 test/rubygems/helper.rb                          | 10 ++++++++++
 test/rubygems/test_gem_commands_setup_command.rb | 12 +++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index bbd6380e6fd..eac6a326752 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -397,6 +397,14 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L397
     @orig_bindir = RbConfig::CONFIG["bindir"]
     RbConfig::CONFIG["bindir"] = File.join @gemhome, "bin"
 
+    @orig_sitelibdir = RbConfig::CONFIG["sitelibdir"]
+    new_sitelibdir = @orig_sitelibdir.sub(RbConfig::CONFIG["prefix"], @gemhome)
+    $LOAD_PATH.insert(Gem.load_path_insert_index, new_sitelibdir)
+    RbConfig::CONFIG["sitelibdir"] = new_sitelibdir
+
+    @orig_mandir = RbConfig::CONFIG["mandir"]
+    RbConfig::CONFIG["mandir"] = File.join @gemhome, "share", "man"
+
     Gem::Specification.unresolved_deps.clear
     Gem.use_paths(@gemhome)
 
@@ -468,6 +476,8 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L476
 
     Gem.ruby = @orig_ruby if @orig_ruby
 
+    RbConfig::CONFIG['mandir'] = @orig_mandir
+    RbConfig::CONFIG['sitelibdir'] = @orig_sitelibdir
     RbConfig::CONFIG['bindir'] = @orig_bindir
 
     Gem.instance_variable_set :@default_specifications_dir, nil
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index b66943610dd..1de9a477dbf 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -14,9 +14,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L14
   def setup
     super
 
-    @install_dir = File.join @tempdir, 'install'
     @cmd = Gem::Commands::SetupCommand.new
-    @cmd.options[:prefix] = @install_dir
 
     filelist = %w[
       bin/gem
@@ -269,7 +267,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L267
   end
 
   def test_remove_old_lib_files
-    lib                   = File.join @install_dir, 'lib'
+    lib                   = RbConfig::CONFIG["sitelibdir"]
     lib_rubygems          = File.join lib, 'rubygems'
     lib_bundler           = File.join lib, 'bundler'
     lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
@@ -300,7 +298,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L298
   end
 
   def test_remove_old_man_files
-    man = File.join @install_dir, 'man'
+    man = File.join RbConfig::CONFIG['mandir'], 'man'
 
     ruby_1             = File.join man, 'man1', 'ruby.1'
     bundle_b_1         = File.join man, 'man1', 'bundle-b.1'
@@ -406,14 +404,14 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L404
   end
 
   def default_gem_bin_path
-    File.join @install_dir, 'bin', 'gem'
+    File.join RbConfig::CONFIG['bindir'], 'gem'
   end
 
   def default_bundle_bin_path
-    File.join @install_dir, 'bin', 'bundle'
+    File.join RbConfig::CONFIG['bindir'], 'bundle'
   end
 
   def default_bundler_bin_path
-    File.join @install_dir, 'bin', 'bundler'
+    File.join RbConfig::CONFIG['bindir'], 'bundler'
   end
 end unless Gem.java_platform?
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]