summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-11-04 20:20:47 +0100
committergit <svn-admin@ruby-lang.org>2021-11-05 23:20:47 +0900
commite60c1f7556878c9e65a6adad537f29c07aea64ee (patch)
tree2c463dfa16b7513504f4a6eb5777dc3867907a8c
parent5b941ec90dd76ddb78a3c9e5179f3eee801b4036 (diff)
[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
-rw-r--r--test/rubygems/helper.rb10
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb12
2 files changed, 15 insertions, 7 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index bbd6380e6f..eac6a32675 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -397,6 +397,14 @@ class Gem::TestCase < Test::Unit::TestCase
@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
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 b66943610d..1de9a477db 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
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
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
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
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?