Skip to content

Commit

Permalink
Refactor setup tests to not always pass --prefix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deivid-rodriguez committed Nov 5, 2021
1 parent 2839d15 commit 50a7e34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 10 additions & 0 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ def setup
@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)

Expand Down Expand Up @@ -468,6 +476,8 @@ def teardown

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
Expand Down
12 changes: 5 additions & 7 deletions test/rubygems/test_gem_commands_setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -269,7 +267,7 @@ def test_install_default_bundler_gem_with_destdir_flag
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'
Expand Down Expand Up @@ -300,7 +298,7 @@ def test_remove_old_lib_files
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'
Expand Down Expand Up @@ -406,14 +404,14 @@ def gem_install_with_plugin(name)
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?

0 comments on commit 50a7e34

Please sign in to comment.