summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:45:11 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 13:50:41 +0300
commit56660de3c6df7a4ff8667ef4047d30d0de169935 (patch)
treedd1e526075687b4b24e089cee50eabc21a6143cc /test
parent560cd5b1f04f30542a294b3d77527d3b12f7cc15 (diff)
Merge rubygems master from upstream.
I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem.rb118
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb25
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb18
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb102
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb15
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb12
-rw-r--r--test/rubygems/test_gem_dependency_list.rb8
-rw-r--r--test/rubygems/test_gem_ext_builder.rb2
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb2
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb8
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb12
-rw-r--r--test/rubygems/test_gem_indexer.rb70
-rw-r--r--test/rubygems/test_gem_install_update_options.rb47
-rw-r--r--test/rubygems/test_gem_installer.rb562
-rw-r--r--test/rubygems/test_gem_package.rb4
-rw-r--r--test/rubygems/test_gem_package_old.rb111
-rw-r--r--test/rubygems/test_gem_package_tar_header.rb41
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb1
-rw-r--r--test/rubygems/test_gem_path_support.rb30
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb9
-rw-r--r--test/rubygems/test_gem_request.rb2
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb2
-rw-r--r--test/rubygems/test_gem_resolver.rb6
-rw-r--r--test/rubygems/test_gem_resolver_activation_request.rb35
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb1
-rw-r--r--test/rubygems/test_gem_security.rb6
-rw-r--r--test/rubygems/test_gem_security_signer.rb1
-rw-r--r--test/rubygems/test_gem_source_git.rb5
-rw-r--r--test/rubygems/test_gem_specification.rb13
-rw-r--r--test/rubygems/test_gem_stub_specification.rb2
-rw-r--r--test/rubygems/test_gem_uninstaller.rb2
-rw-r--r--test/rubygems/test_gem_util.rb14
-rw-r--r--test/rubygems/test_gem_validator.rb7
-rw-r--r--test/rubygems/test_require.rb7
37 files changed, 734 insertions, 584 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index af927ffa29..c90ad2d41a 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -465,55 +465,43 @@ class TestGem < Gem::TestCase
end
def test_default_path
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
+ vendordir(File.join(@tempdir, 'vendor')) do
+ FileUtils.rm_rf Gem.user_home
- FileUtils.rm_rf Gem.user_home
+ expected = [Gem.default_dir]
- expected = [Gem.default_dir]
-
- assert_equal expected, Gem.default_path
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ assert_equal expected, Gem.default_path
+ end
end
def test_default_path_missing_vendor
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG.delete 'vendordir'
-
- FileUtils.rm_rf Gem.user_home
+ vendordir(nil) do
+ FileUtils.rm_rf Gem.user_home
- expected = [Gem.default_dir]
+ expected = [Gem.default_dir]
- assert_equal expected, Gem.default_path
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ assert_equal expected, Gem.default_path
+ end
end
def test_default_path_user_home
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
+ vendordir(File.join(@tempdir, 'vendor')) do
+ expected = [Gem.user_dir, Gem.default_dir]
- expected = [Gem.user_dir, Gem.default_dir]
-
- assert_equal expected, Gem.default_path
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ assert_equal expected, Gem.default_path
+ end
end
def test_default_path_vendor_dir
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG['vendordir'] = File.join @tempdir, 'vendor'
-
- FileUtils.mkdir_p Gem.vendor_dir
+ vendordir(File.join(@tempdir, 'vendor')) do
+ FileUtils.mkdir_p Gem.vendor_dir
- FileUtils.rm_rf Gem.user_home
+ FileUtils.rm_rf Gem.user_home
- expected = [Gem.default_dir, Gem.vendor_dir]
+ expected = [Gem.default_dir, Gem.vendor_dir]
- assert_equal expected, Gem.default_path
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ assert_equal expected, Gem.default_path
+ end
end
def test_self_default_sources
@@ -706,7 +694,7 @@ class TestGem < Gem::TestCase
assert_equal expected, Gem.find_files('sff/discover').sort
assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
ensure
- assert_equal cwd, actual_load_path.shift
+ assert_equal cwd, actual_load_path.shift unless Gem.java_platform?
end
def test_self_find_latest_files
@@ -1232,10 +1220,12 @@ class TestGem < Gem::TestCase
refute Gem.try_activate 'nonexistent'
end
- expected = "Ignoring ext-1 because its extensions are not built. " +
- "Try: gem pristine ext --version 1\n"
+ unless Gem.java_platform?
+ expected = "Ignoring ext-1 because its extensions are not built. " +
+ "Try: gem pristine ext --version 1\n"
- assert_equal expected, err
+ assert_equal expected, err
+ end
end
def test_self_use_paths_with_nils
@@ -1303,7 +1293,6 @@ class TestGem < Gem::TestCase
end
def test_self_needs
- util_clear_gems
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
@@ -1322,7 +1311,6 @@ class TestGem < Gem::TestCase
def test_self_needs_picks_up_unresolved_deps
save_loaded_features do
- util_clear_gems
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
@@ -1364,11 +1352,13 @@ class TestGem < Gem::TestCase
end
def test_self_vendor_dir
- expected =
- File.join RbConfig::CONFIG['vendordir'], 'gems',
- RbConfig::CONFIG['ruby_version']
+ vendordir(File.join(@tempdir, 'vendor')) do
+ expected =
+ File.join RbConfig::CONFIG['vendordir'], 'gems',
+ RbConfig::CONFIG['ruby_version']
- assert_equal expected, Gem.vendor_dir
+ assert_equal expected, Gem.vendor_dir
+ end
end
def test_self_vendor_dir_ENV_GEM_VENDOR
@@ -1379,12 +1369,9 @@ class TestGem < Gem::TestCase
end
def test_self_vendor_dir_missing
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG.delete 'vendordir'
-
- assert_nil Gem.vendor_dir
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ vendordir(nil) do
+ assert_nil Gem.vendor_dir
+ end
end
def test_load_plugins
@@ -1514,8 +1501,6 @@ class TestGem < Gem::TestCase
end
def test_auto_activation_of_specific_gemdeps_file
- util_clear_gems
-
a = util_spec "a", "1", nil, "lib/a.rb"
b = util_spec "b", "1", nil, "lib/b.rb"
c = util_spec "c", "1", nil, "lib/c.rb"
@@ -1538,8 +1523,6 @@ class TestGem < Gem::TestCase
end
def test_auto_activation_of_used_gemdeps_file
- util_clear_gems
-
a = util_spec "a", "1", nil, "lib/a.rb"
b = util_spec "b", "1", nil, "lib/b.rb"
c = util_spec "c", "1", nil, "lib/c.rb"
@@ -1571,7 +1554,7 @@ class TestGem < Gem::TestCase
end
def test_looks_for_gemdeps_files_automatically_on_start
- util_clear_gems
+ skip "Requiring bundler messes things up" if Gem.java_platform?
a = util_spec "a", "1", nil, "lib/a.rb"
b = util_spec "b", "1", nil, "lib/b.rb"
@@ -1607,7 +1590,7 @@ class TestGem < Gem::TestCase
end
def test_looks_for_gemdeps_files_automatically_on_start_in_parent_dir
- util_clear_gems
+ skip "Requiring bundler messes things up" if Gem.java_platform?
a = util_spec "a", "1", nil, "lib/a.rb"
b = util_spec "b", "1", nil, "lib/b.rb"
@@ -1674,33 +1657,6 @@ class TestGem < Gem::TestCase
assert_nil Gem.find_unresolved_default_spec("README")
end
- def test_default_gems_use_full_paths
- begin
- if defined?(RUBY_ENGINE)
- engine = RUBY_ENGINE
- Object.send :remove_const, :RUBY_ENGINE
- end
- Object.const_set :RUBY_ENGINE, 'ruby'
-
- refute Gem.default_gems_use_full_paths?
- ensure
- Object.send :remove_const, :RUBY_ENGINE
- Object.const_set :RUBY_ENGINE, engine if engine
- end
-
- begin
- if defined?(RUBY_ENGINE)
- engine = RUBY_ENGINE
- Object.send :remove_const, :RUBY_ENGINE
- end
- Object.const_set :RUBY_ENGINE, 'jruby'
- assert Gem.default_gems_use_full_paths?
- ensure
- Object.send :remove_const, :RUBY_ENGINE
- Object.const_set :RUBY_ENGINE, engine if engine
- end
- end
-
def test_use_gemdeps
gem_deps_file = 'gem.deps.rb'.untaint
spec = util_spec 'a', 1
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index 6441587cf6..58fc9648bf 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -281,7 +281,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_signed_gem
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
trust_dir = Gem::Security.trust_dir
@@ -308,7 +308,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_signed_gem_with_cert_expiration_length_days
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
Dir.mkdir gem_path
@@ -352,7 +352,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
end
def test_build_auto_resign_cert
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform?
gem_path = File.join Gem.user_home, ".gem"
Dir.mkdir gem_path
@@ -389,7 +389,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
output = @ui.output.split "\n"
assert_equal "INFO: Your certificate has expired, trying to re-sign it...", output.shift
assert_equal "INFO: Your cert: #{tmp_expired_cert_file } has been auto re-signed with the key: #{tmp_private_key_file}", output.shift
- assert_match /INFO: Your expired cert will be located at: .+\Wgem-public_cert\.pem\.expired\.[0-9]+/, output.shift
+ assert_match(/INFO: Your expired cert will be located at: .+\Wgem-public_cert\.pem\.expired\.[0-9]+/, output.shift)
end
end
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index d7381f14d0..e9e1a353c1 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -6,6 +6,10 @@ unless defined?(OpenSSL::SSL)
warn 'Skipping `gem cert` tests. openssl not found.'
end
+if Gem.java_platform?
+ warn 'Skipping `gem cert` tests on jruby.'
+end
+
class TestGemCommandsCertCommand < Gem::TestCase
ALTERNATE_CERT = load_cert 'alternate'
@@ -793,4 +797,4 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
e.message
end
-end if defined?(OpenSSL::SSL)
+end if defined?(OpenSSL::SSL) && !Gem.java_platform?
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index 71cf386026..6183e592e9 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -459,7 +459,28 @@ pl (1 i386-linux)
EOF
assert_equal expected, @stub_ui.output
- assert_equal "WARNING: prereleases are always shown locally\n", @stub_ui.error
+ end
+
+ def test_execute_no_prerelease_local
+ spec_fetcher do |fetcher|
+ fetcher.legacy_platform
+ end
+
+ @cmd.handle_options %w[-l --no-prerelease]
+
+ use_ui @stub_ui do
+ @cmd.execute
+ end
+
+ expected = <<-EOF
+
+*** LOCAL GEMS ***
+
+a (2, 1)
+pl (1 i386-linux)
+ EOF
+
+ assert_equal expected, @stub_ui.output
end
def test_execute_remote
@@ -569,7 +590,7 @@ pl (1 i386-linux)
@cmd.options[:domain] = :remote
use_ui @stub_ui do
- @cmd.send :show_gems, /a/i, false
+ @cmd.send :show_gems, /a/i
end
assert_match %r%^a %, @stub_ui.output
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 3f9887eedf..0345386804 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -189,7 +189,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_path_exists File.join(bin_dir, "#{e}.bat")
end
- assert_path_exists File.join bin_dir, e
+ assert_path_exists File.join bin_dir, Gem.default_exec_format % e
end
default_dir = Gem::Specification.default_specifications_dir
@@ -323,4 +323,4 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@ui.outs.set_encoding @default_external if @default_external
end
-end
+end unless Gem.java_platform?
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 1e58643566..36e6ee9293 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -7,11 +7,17 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
def setup
super
- spec_fetcher
-
@cmd = Gem::Commands::SourcesCommand.new
@new_repo = "http://beta-gems.example.com"
+
+ @old_https_proxy_config = Gem.configuration[:http_proxy]
+ end
+
+ def teardown
+ Gem.configuration[:http_proxy] = @old_https_proxy_config
+
+ super
end
def test_initialize_proxy
@@ -69,6 +75,8 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
end
def test_execute_add_nonexistent_source
+ spec_fetcher
+
uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz"
@fetcher.data[uri] = proc do
raise Gem::RemoteFetcher::FetchError.new('it died', uri)
@@ -92,6 +100,8 @@ Error fetching http://beta-gems.example.com:
end
def test_execute_add_redundant_source
+ spec_fetcher
+
@cmd.handle_options %W[--add #{@gem_repo}]
use_ui @ui do
@@ -109,6 +119,8 @@ source #{@gem_repo} already present in the cache
end
def test_execute_add_redundant_source_trailing_slash
+ spec_fetcher
+
# Remove pre-existing gem source (w/ slash)
repo_with_slash = "http://gems.example.com/"
@cmd.handle_options %W[--remove #{repo_with_slash}]
@@ -266,6 +278,8 @@ beta-gems.example.com is not a URI
end
def test_execute_remove_no_network
+ spec_fetcher
+
@cmd.handle_options %W[--remove #{@gem_repo}]
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb
index 34b1838486..4ac06977e3 100644
--- a/test/rubygems/test_gem_commands_uninstall_command.rb
+++ b/test/rubygems/test_gem_commands_uninstall_command.rb
@@ -6,19 +6,13 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
def setup
super
- common_installer_setup
-
- build_rake_in do
- use_ui @ui do
- @installer.install
- end
- end
-
@cmd = Gem::Commands::UninstallCommand.new
@executable = File.join(@gemhome, 'bin', 'executable')
end
def test_execute_all_named
+ initial_install
+
util_make_gems
default = new_default_spec 'default', '1'
@@ -48,6 +42,8 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_dependency_order
+ initial_install
+
c = quick_gem 'c' do |spec|
spec.add_dependency 'a'
end
@@ -76,15 +72,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_removes_executable
- ui = Gem::MockGemUi.new
-
- util_setup_gem ui
-
- build_rake_in do
- use_ui ui do
- @installer.install
- end
- end
+ initial_install
if win_platform?
assert File.exist?(@executable)
@@ -113,12 +101,14 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_removes_formatted_executable
+ installer = setup_base_installer
+
FileUtils.rm_f @executable # Wish this didn't happen in #setup
Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.format_executable = true
- @installer.install
+ installer.format_executable = true
+ installer.install
formatted_executable = File.join @gemhome, 'bin', 'foo-executable-bar'
assert_equal true, File.exist?(formatted_executable)
@@ -137,11 +127,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
@gem = File.join @tempdir, @spec.file_name
FileUtils.touch @gem
- util_setup_gem
+ installer = util_setup_gem
build_rake_in do
use_ui @ui do
- @installer.install
+ installer.install
end
end
@@ -157,10 +147,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_with_version_leaves_non_matching_versions
+ initial_install
+
ui = Gem::MockGemUi.new
util_make_gems
- util_setup_gem ui
assert_equal 3, Gem::Specification.find_all_by_name('a').length
@@ -178,10 +169,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_with_version_specified_as_colon
+ initial_install
+
ui = Gem::MockGemUi.new "y\n"
util_make_gems
- util_setup_gem ui
assert_equal 3, Gem::Specification.find_all_by_name('a').length
@@ -254,6 +246,8 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_with_force_and_without_version_uninstalls_everything
+ initial_install
+
ui = Gem::MockGemUi.new "y\n"
a_1, = util_gem 'a', 1
@@ -262,8 +256,6 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
a_3a, = util_gem 'a', '3.a'
install_gem a_3a
- util_setup_gem ui
-
assert_equal 3, Gem::Specification.find_all_by_name('a').length
@cmd.options[:force] = true
@@ -279,10 +271,11 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_execute_with_force_ignores_dependencies
+ initial_install
+
ui = Gem::MockGemUi.new
util_make_gems
- util_setup_gem ui
assert Gem::Specification.find_all_by_name('dep_x').length > 0
assert Gem::Specification.find_all_by_name('x').length > 0
@@ -359,20 +352,22 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
def test_handle_options_vendor
- use_ui @ui do
- @cmd.handle_options %w[--vendor]
- end
+ vendordir(File.join(@tempdir, 'vendor')) do
+ use_ui @ui do
+ @cmd.handle_options %w[--vendor]
+ end
- assert @cmd.options[:vendor]
- assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
+ assert @cmd.options[:vendor]
+ assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
- assert_empty @ui.output
+ assert_empty @ui.output
- expected = <<-EXPECTED
+ expected = <<-EXPECTED
WARNING: Use your OS package manager to uninstall vendor gems
- EXPECTED
+ EXPECTED
- assert_match expected, @ui.error
+ assert_match expected, @ui.error
+ end
end
def test_execute_two_version
@@ -395,21 +390,17 @@ WARNING: Use your OS package manager to uninstall vendor gems
end
def test_handle_options_vendor_missing
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG.delete 'vendordir'
-
- e = assert_raises OptionParser::InvalidOption do
- @cmd.handle_options %w[--vendor]
- end
-
- assert_equal 'invalid option: --vendor your platform is not supported',
- e.message
+ vendordir(nil) do
+ e = assert_raises OptionParser::InvalidOption do
+ @cmd.handle_options %w[--vendor]
+ end
- refute @cmd.options[:vendor]
- refute @cmd.options[:install_dir]
+ assert_equal 'invalid option: --vendor your platform is not supported',
+ e.message
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ refute @cmd.options[:vendor]
+ refute @cmd.options[:install_dir]
+ end
end
def test_execute_with_gem_not_installed
@@ -425,6 +416,8 @@ WARNING: Use your OS package manager to uninstall vendor gems
end
def test_execute_with_gem_uninstall_error
+ initial_install
+
util_make_gems
@cmd.options[:args] = %w[a]
@@ -451,4 +444,17 @@ WARNING: Use your OS package manager to uninstall vendor gems
assert_match %r!Error: unable to successfully uninstall '#{@spec.name}'!, @ui.error
end
+ private
+
+ def initial_install
+ installer = setup_base_installer
+ common_installer_setup
+
+ build_rake_in do
+ use_ui @ui do
+ installer.install
+ end
+ end
+ end
+
end
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 77851d32d6..d9ee5f8468 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -504,25 +504,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_equal '--prefix', arguments.shift
assert_equal Gem.prefix, arguments.shift
- assert_equal '--no-rdoc', arguments.shift
- assert_equal '--no-ri', arguments.shift
+ assert_equal '--no-document', arguments.shift
assert_equal '--previous-version', arguments.shift
assert_equal Gem::VERSION, arguments.shift
assert_empty arguments
end
- def test_update_rubygems_arguments_1_8_x
- @cmd.options[:system] = '1.8.26'
-
- arguments = @cmd.update_rubygems_arguments
-
- assert_equal '--prefix', arguments.shift
- assert_equal Gem.prefix, arguments.shift
- assert_equal '--no-rdoc', arguments.shift
- assert_equal '--no-ri', arguments.shift
- assert_empty arguments
- end
-
def test_explain
spec_fetcher do |fetcher|
fetcher.download 'a', 2
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 48912ee0cd..15fc8c7c28 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -45,7 +45,6 @@ class TestGemDependencyInstaller < Gem::TestCase
s.add_development_dependency 'c'
end
- util_clear_gems
util_reset_gems
end
@@ -133,7 +132,6 @@ class TestGemDependencyInstaller < Gem::TestCase
p1a, gem = util_gem 'a', '10.a'
util_setup_spec_fetcher(p1a, @a1, @a1_pre)
- util_clear_gems
p1a_data = Gem.read_binary(gem)
@@ -172,7 +170,6 @@ class TestGemDependencyInstaller < Gem::TestCase
p1a, gem = util_gem 'p', '1.a'
util_setup_spec_fetcher(p1a)
- util_clear_gems
p1a_data = Gem.read_binary(gem)
@@ -192,7 +189,6 @@ class TestGemDependencyInstaller < Gem::TestCase
util_setup_gems
util_setup_spec_fetcher(@a1, @a1_pre)
- util_clear_gems
p1a_data = Gem.read_binary(@a1_gem)
@@ -213,8 +209,6 @@ class TestGemDependencyInstaller < Gem::TestCase
s.add_dependency 'b'
end
- util_clear_gems
-
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv e1_gem, @tempdir
@@ -575,8 +569,6 @@ class TestGemDependencyInstaller < Gem::TestCase
s.add_dependency 'a'
end
- util_clear_gems
-
FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv b2_gem, @tempdir
@@ -877,8 +869,6 @@ class TestGemDependencyInstaller < Gem::TestCase
si = util_setup_spec_fetcher @a1, a2_o
- util_clear_gems
-
@fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
a1_data = nil
@@ -1274,8 +1264,6 @@ class TestGemDependencyInstaller < Gem::TestCase
util_setup_spec_fetcher(*[@a1, @a1_pre, @b1, @c1_pre,
@d1, @d2, @x1_m, @x1_o, @w1, @y1,
@y1_1_p, @z1].compact)
-
- util_clear_gems
end
end
diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb
index 019cb33973..6bf803fe5f 100644
--- a/test/rubygems/test_gem_dependency_list.rb
+++ b/test/rubygems/test_gem_dependency_list.rb
@@ -7,8 +7,6 @@ class TestGemDependencyList < Gem::TestCase
def setup
super
- util_clear_gems
-
@deplist = Gem::DependencyList.new
# TODO: switch to util_spec
@@ -124,8 +122,6 @@ class TestGemDependencyList < Gem::TestCase
end
def test_ok_eh
- util_clear_gems
-
assert @deplist.ok?, 'no dependencies'
@deplist.add @b2
@@ -138,8 +134,6 @@ class TestGemDependencyList < Gem::TestCase
end
def test_why_not_ok_eh
- util_clear_gems
-
assert_equal({}, @deplist.why_not_ok?)
@deplist.add @b2
@@ -229,8 +223,6 @@ class TestGemDependencyList < Gem::TestCase
end
def test_remove_by_name
- util_clear_gems
-
@deplist.add @a1, @b2
@deplist.remove_by_name "a-1"
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb
index 46a4385750..7091acdca0 100644
--- a/test/rubygems/test_gem_ext_builder.rb
+++ b/test/rubygems/test_gem_ext_builder.rb
@@ -329,4 +329,4 @@ install:
assert_equal %w[--with-foo-dir=/nonexistent], builder.build_args
end
-end
+end unless Gem.java_platform?
diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb
index 757266cae2..f7dc383fe9 100644
--- a/test/rubygems/test_gem_ext_cmake_builder.rb
+++ b/test/rubygems/test_gem_ext_cmake_builder.rb
@@ -10,6 +10,8 @@ class TestGemExtCmakeBuilder < Gem::TestCase
# Details: https://github.com/rubygems/rubygems/issues/1270#issuecomment-177368340
skip "CmakeBuilder doesn't work on Windows." if Gem.win_platform?
+ skip "CmakeBuilder doesn't work on JRuby." if Gem.java_platform? && ENV["CI"]
+
system('cmake', out: IO::NULL, err: [:child, :out])
skip 'cmake not present' unless $?.success?
diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb
index 967458170b..eeeb654ae9 100644
--- a/test/rubygems/test_gem_ext_configure_builder.rb
+++ b/test/rubygems/test_gem_ext_configure_builder.rb
@@ -18,6 +18,10 @@ class TestGemExtConfigureBuilder < Gem::TestCase
end
def test_self_build
+ if java_platform? && ENV["CI"]
+ skip("failing on jruby")
+ end
+
skip("test_self_build skipped on MS Windows (VC++)") if vc_windows?
File.open File.join(@ext, './configure'), 'w' do |configure|
@@ -45,6 +49,10 @@ class TestGemExtConfigureBuilder < Gem::TestCase
end
def test_self_build_fail
+ if java_platform? && ENV["CI"]
+ skip("failing on jruby")
+ end
+
skip("test_self_build_fail skipped on MS Windows (VC++)") if vc_windows?
output = []
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
index 6decb29a99..d92da46f92 100644
--- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
+++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb
@@ -17,6 +17,10 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
def test_class_build
+ if java_platform? && ENV["CI"]
+ skip("failing on jruby")
+ end
+
if vc_windows? && !nmake_found?
skip("test_class_build skipped - nmake not found")
end
@@ -45,6 +49,10 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end
def test_class_build_rbconfig_make_prog
+ if java_platform? && ENV["CI"]
+ skip("failing on jruby")
+ end
+
configure_args do
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
@@ -68,6 +76,10 @@ class TestGemExtExtConfBuilder < Gem::TestCase
env_make = ENV.delete 'MAKE'
ENV['MAKE'] = 'anothermake'
+ if java_platform? && ENV["CI"]
+ skip("failing on jruby")
+ end
+
configure_args '' do
File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index ce08702c41..43a04c3bb3 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -11,7 +11,6 @@ class TestGemIndexer < Gem::TestCase
def setup
super
- util_clear_gems
util_make_gems
@d2_0 = util_spec 'd', '2.0' do |s|
@@ -28,30 +27,23 @@ class TestGemIndexer < Gem::TestCase
@default = new_default_spec 'default', 2
install_default_gems @default
- @tempdir = File.join(@tempdir, 'indexer')
+ @indexerdir = File.join(@tempdir, 'indexer')
- gems = File.join(@tempdir, 'gems')
+ gems = File.join(@indexerdir, 'gems')
FileUtils.mkdir_p gems
FileUtils.mv Dir[File.join(@gemhome, "cache", '*.gem')], gems
- @indexer = Gem::Indexer.new(@tempdir)
- end
-
- def teardown
- super
-
- util_clear_gems
- util_clear_default_gems
+ @indexer = Gem::Indexer.new(@indexerdir)
end
def test_initialize
- assert_equal @tempdir, @indexer.dest_directory
+ assert_equal @indexerdir, @indexer.dest_directory
assert_match %r{#{Dir.mktmpdir('gem_generate_index').match(/.*-/)}}, @indexer.directory
- indexer = Gem::Indexer.new @tempdir
+ indexer = Gem::Indexer.new @indexerdir
assert indexer.build_modern
- indexer = Gem::Indexer.new @tempdir, :build_modern => true
+ indexer = Gem::Indexer.new @indexerdir, :build_modern => true
assert indexer.build_modern
end
@@ -100,7 +92,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- quickdir = File.join @tempdir, 'quick'
+ quickdir = File.join @indexerdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
assert_directory_exists quickdir
@@ -111,11 +103,11 @@ class TestGemIndexer < Gem::TestCase
refute_indexed marshal_quickdir, File.basename(@c1_2.spec_file)
- assert_indexed @tempdir, "specs.#{@marshal_version}"
- assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_modern
@@ -125,12 +117,12 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- refute_indexed @tempdir, 'yaml'
- refute_indexed @tempdir, 'yaml.Z'
- refute_indexed @tempdir, "Marshal.#{@marshal_version}"
- refute_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
+ refute_indexed @indexerdir, 'yaml'
+ refute_indexed @indexerdir, 'yaml.Z'
+ refute_indexed @indexerdir, "Marshal.#{@marshal_version}"
+ refute_indexed @indexerdir, "Marshal.#{@marshal_version}.Z"
- quickdir = File.join @tempdir, 'quick'
+ quickdir = File.join @indexerdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
assert_directory_exists quickdir, 'quickdir should be directory'
@@ -156,11 +148,11 @@ class TestGemIndexer < Gem::TestCase
refute_indexed quickdir, "#{File.basename(@c1_2.spec_file)}"
refute_indexed marshal_quickdir, "#{File.basename(@c1_2.spec_file)}"
- assert_indexed @tempdir, "specs.#{@marshal_version}"
- assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_modern_back_to_back
@@ -170,13 +162,13 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- @indexer = Gem::Indexer.new @tempdir
+ @indexer = Gem::Indexer.new @indexerdir
@indexer.build_modern = true
use_ui @ui do
@indexer.generate_index
end
- quickdir = File.join @tempdir, 'quick'
+ quickdir = File.join @indexerdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
assert_directory_exists quickdir
@@ -185,11 +177,11 @@ class TestGemIndexer < Gem::TestCase
assert_indexed marshal_quickdir, "#{File.basename(@a1.spec_file)}.rz"
assert_indexed marshal_quickdir, "#{File.basename(@a2.spec_file)}.rz"
- assert_indexed @tempdir, "specs.#{@marshal_version}"
- assert_indexed @tempdir, "specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "specs.#{@marshal_version}.gz"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}"
- assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
+ assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
end
def test_generate_index_ui
@@ -215,7 +207,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- specs_path = File.join @tempdir, "specs.#{@marshal_version}"
+ specs_path = File.join @indexerdir, "specs.#{@marshal_version}"
specs_dump = Gem.read_binary specs_path
specs = Marshal.load specs_dump
@@ -252,7 +244,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- latest_specs_path = File.join @tempdir, "latest_specs.#{@marshal_version}"
+ latest_specs_path = File.join @indexerdir, "latest_specs.#{@marshal_version}"
latest_specs_dump = Gem.read_binary latest_specs_path
latest_specs = Marshal.load latest_specs_dump
@@ -282,7 +274,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- prerelease_specs_path = File.join @tempdir, "prerelease_specs.#{@marshal_version}"
+ prerelease_specs_path = File.join @indexerdir, "prerelease_specs.#{@marshal_version}"
prerelease_specs_dump = Gem.read_binary prerelease_specs_path
prerelease_specs = Marshal.load prerelease_specs_dump
@@ -311,7 +303,7 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
- quickdir = File.join @tempdir, 'quick'
+ quickdir = File.join @indexerdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
assert_directory_exists quickdir
@@ -325,7 +317,7 @@ class TestGemIndexer < Gem::TestCase
util_build_gem @d2_1_a
@d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform]
- gems = File.join @tempdir, 'gems'
+ gems = File.join @indexerdir, 'gems'
FileUtils.mv @d2_1.cache_file, gems
FileUtils.mv @d2_1_a.cache_file, gems
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
index dd6bd08dde..c6b4778336 100644
--- a/test/rubygems/test_gem_install_update_options.rb
+++ b/test/rubygems/test_gem_install_update_options.rb
@@ -26,10 +26,11 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
-f
-i /install_to
-w
- --vendor
--post-install-message
]
+ args.concat %w[--vendor] unless Gem.java_platform?
+
args.concat %w[-P HighSecurity] if defined?(OpenSSL::SSL)
assert @cmd.handles?(args)
@@ -111,6 +112,13 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_user_install_enabled
+ @spec = quick_gem 'a' do |spec|
+ util_make_exec spec
+ end
+
+ util_build_gem @spec
+ @gem = @spec.cache_file
+
@cmd.handle_options %w[--user-install]
assert @cmd.options[:user_install]
@@ -122,6 +130,13 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_user_install_disabled_read_only
+ @spec = quick_gem 'a' do |spec|
+ util_make_exec spec
+ end
+
+ util_build_gem @spec
+ @gem = @spec.cache_file
+
if win_platform?
skip('test_user_install_disabled_read_only test skipped on MS Windows')
elsif Process.uid.zero?
@@ -145,28 +160,26 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
end
def test_vendor
- @cmd.handle_options %w[--vendor]
+ vendordir(File.join(@tempdir, 'vendor')) do
+ @cmd.handle_options %w[--vendor]
- assert @cmd.options[:vendor]
- assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
+ assert @cmd.options[:vendor]
+ assert_equal Gem.vendor_dir, @cmd.options[:install_dir]
+ end
end
def test_vendor_missing
- orig_vendordir = RbConfig::CONFIG['vendordir']
- RbConfig::CONFIG.delete 'vendordir'
-
- e = assert_raises OptionParser::InvalidOption do
- @cmd.handle_options %w[--vendor]
- end
-
- assert_equal 'invalid option: --vendor your platform is not supported',
- e.message
+ vendordir(nil) do
+ e = assert_raises OptionParser::InvalidOption do
+ @cmd.handle_options %w[--vendor]
+ end
- refute @cmd.options[:vendor]
- refute @cmd.options[:install_dir]
+ assert_equal 'invalid option: --vendor your platform is not supported',
+ e.message
- ensure
- RbConfig::CONFIG['vendordir'] = orig_vendordir
+ refute @cmd.options[:vendor]
+ refute @cmd.options[:install_dir]
+ end
end
def test_post_install_message_no
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 7f325080ec..0e611b60ea 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -22,11 +22,6 @@ class TestGemInstaller < Gem::InstallerTestCase
super
common_installer_setup
- if (self.class.method_defined?(:__name__) ? __name__ : name) =~ /\Atest_install(_|\Z)/
- FileUtils.rm_r @spec.gem_dir
- FileUtils.rm_r @user_spec.gem_dir
- end
-
@config = Gem.configuration
end
@@ -39,6 +34,8 @@ class TestGemInstaller < Gem::InstallerTestCase
end
def test_app_script_text
+ installer = setup_base_installer
+
util_make_exec @spec, ''
expected = <<-EOF
@@ -71,12 +68,14 @@ load Gem.bin_path("a", "executable", version)
end
EOF
- wrapper = @installer.app_script_text 'executable'
+ wrapper = installer.app_script_text 'executable'
assert_equal expected, wrapper
end
def test_check_executable_overwrite
- @installer.generate_bin
+ installer = setup_base_installer
+
+ installer.generate_bin
@spec = Gem::Specification.new do |s|
s.files = ['lib/code.rb']
@@ -88,9 +87,9 @@ end
end
util_make_exec
- @installer.gem_dir = @spec.gem_dir
- @installer.wrappers = true
- @installer.generate_bin
+ installer.gem_dir = @spec.gem_dir
+ installer.wrappers = true
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -100,6 +99,8 @@ end
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
@@ -112,7 +113,7 @@ end
ui = Gem::MockGemUi.new "n\n"
use_ui ui do
e = assert_raises Gem::InstallError do
- @installer.generate_bin
+ installer.generate_bin
end
conflicted = File.join @gemhome, 'bin', 'executable'
@@ -130,7 +131,9 @@ end
end
def test_check_executable_overwrite_format_executable
- @installer.generate_bin
+ installer = setup_base_installer
+
+ installer.generate_bin
@spec = Gem::Specification.new do |s|
s.files = ['lib/code.rb']
@@ -153,11 +156,11 @@ gem 'other', version
util_make_exec
Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.gem_dir = @spec.gem_dir
- @installer.wrappers = true
- @installer.format_executable = true
+ installer.gem_dir = @spec.gem_dir
+ installer.wrappers = true
+ installer.format_executable = true
- @installer.generate_bin # should not raise
+ installer.generate_bin # should not raise
installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
assert_path_exists installed_exec
@@ -169,13 +172,15 @@ gem 'other', version
end
def test_check_executable_overwrite_other_gem
+ installer = setup_base_installer
+
util_conflict_executable true
ui = Gem::MockGemUi.new "n\n"
use_ui ui do
e = assert_raises Gem::InstallError do
- @installer.generate_bin
+ installer.generate_bin
end
assert_equal '"executable" from a conflicts with installed executable from conflict',
@@ -184,11 +189,13 @@ gem 'other', version
end
def test_check_executable_overwrite_other_gem_force
+ installer = setup_base_installer
+
util_conflict_executable true
- @installer.wrappers = true
- @installer.force = true
+ installer.wrappers = true
+ installer.force = true
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -198,10 +205,12 @@ gem 'other', version
end
def test_check_executable_overwrite_other_non_gem
+ installer = setup_base_installer
+
util_conflict_executable false
- @installer.wrappers = true
+ installer.wrappers = true
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -211,7 +220,9 @@ gem 'other', version
end unless Gem.win_platform?
def test_check_that_user_bin_dir_is_in_path
- bin_dir = @installer.bin_dir
+ installer = setup_base_installer
+
+ bin_dir = installer.bin_dir
if Gem.win_platform?
bin_dir = bin_dir.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
@@ -221,7 +232,7 @@ gem 'other', version
ENV['PATH'], [ENV['PATH'], bin_dir].join(File::PATH_SEPARATOR)
use_ui @ui do
- @installer.check_that_user_bin_dir_is_in_path
+ installer.check_that_user_bin_dir_is_in_path
end
assert_empty @ui.error
@@ -235,10 +246,11 @@ gem 'other', version
orig_PATH, ENV['PATH'] =
ENV['PATH'], [ENV['PATH'], '~/bin'].join(File::PATH_SEPARATOR)
- @installer.bin_dir.replace File.join @userhome, 'bin'
+ installer = setup_base_installer
+ installer.bin_dir.replace File.join @userhome, 'bin'
use_ui @ui do
- @installer.check_that_user_bin_dir_is_in_path
+ installer.check_that_user_bin_dir_is_in_path
end
assert_empty @ui.error
@@ -247,11 +259,13 @@ gem 'other', version
end
def test_check_that_user_bin_dir_is_in_path_not_in_path
+ installer = setup_base_installer
+
use_ui @ui do
- @installer.check_that_user_bin_dir_is_in_path
+ installer.check_that_user_bin_dir_is_in_path
end
- expected = @installer.bin_dir
+ expected = installer.bin_dir
if Gem.win_platform?
expected = expected.downcase.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
@@ -261,14 +275,16 @@ gem 'other', version
end
def test_ensure_dependency
+ installer = setup_base_installer
+
util_spec 'a'
dep = Gem::Dependency.new 'a', '>= 2'
- assert @installer.ensure_dependency(@spec, dep)
+ assert installer.ensure_dependency(@spec, dep)
dep = Gem::Dependency.new 'b', '> 2'
e = assert_raises Gem::InstallError do
- @installer.ensure_dependency @spec, dep
+ installer.ensure_dependency @spec, dep
end
assert_equal 'a requires b (> 2)', e.message
@@ -305,26 +321,30 @@ gem 'other', version
end
def test_extract_files
- @installer.extract_files
+ installer = setup_base_installer
+
+ installer.extract_files
assert_path_exists File.join @spec.gem_dir, 'bin/executable'
end
def test_generate_bin_bindir
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
@spec.executables = %w[executable]
@spec.bindir = 'bin'
- exec_file = @installer.formatted_program_filename 'executable'
+ exec_file = installer.formatted_program_filename 'executable'
exec_path = File.join @spec.gem_dir, exec_file
File.open exec_path, 'w' do |f|
f.puts '#!/usr/bin/ruby'
end
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
installed_exec = File.join(util_inst_bindir, 'executable')
@@ -362,11 +382,13 @@ gem 'other', version
end
def test_generate_bin_script
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -377,13 +399,15 @@ gem 'other', version
end
def test_generate_bin_script_format
- @installer.format_executable = true
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.format_executable = true
+ installer.wrappers = true
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
assert_path_exists installed_exec
@@ -392,12 +416,14 @@ gem 'other', version
end
def test_generate_bin_script_format_disabled
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -406,7 +432,9 @@ gem 'other', version
end
def test_generate_bin_script_install_dir
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name)
gem_bindir = File.join gem_dir, 'bin'
@@ -415,11 +443,11 @@ gem 'other', version
f.puts "#!/bin/ruby"
end
- @installer.gem_home = "#{@gemhome}2"
- @installer.gem_dir = gem_dir
- @installer.bin_dir = File.join "#{@gemhome}2", 'bin'
+ installer.gem_home = "#{@gemhome}2"
+ installer.gem_dir = gem_dir
+ installer.bin_dir = File.join "#{@gemhome}2", 'bin'
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join("#{@gemhome}2", "bin", 'executable')
assert_path_exists installed_exec
@@ -430,16 +458,20 @@ gem 'other', version
end
def test_generate_bin_script_no_execs
- util_execless
+ installer = setup_base_installer
- @installer.wrappers = true
- @installer.generate_bin
+ installer = util_execless
+
+ installer.wrappers = true
+ installer.generate_bin
refute_path_exists util_inst_bindir, 'bin dir was created when not needed'
end
def test_generate_bin_script_no_perms
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
Dir.mkdir util_inst_bindir
@@ -452,7 +484,7 @@ gem 'other', version
FileUtils.chmod 0000, util_inst_bindir
assert_raises Gem::FilePermissionError do
- @installer.generate_bin
+ installer.generate_bin
end
end
ensure
@@ -460,7 +492,9 @@ gem 'other', version
end
def test_generate_bin_script_no_shebang
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
@spec.executables = %w[executable]
gem_dir = File.join @gemhome, 'gems', @spec.full_name
@@ -470,7 +504,7 @@ gem 'other', version
f.puts "blah blah blah"
end
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join @gemhome, 'bin', 'executable'
assert_path_exists installed_exec
@@ -483,9 +517,11 @@ gem 'other', version
end
def test_generate_bin_script_wrappers
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
installed_exec = File.join(util_inst_bindir, 'executable')
real_exec = File.join @spec.gem_dir, 'bin', 'executable'
@@ -496,7 +532,7 @@ gem 'other', version
FileUtils.ln_s real_exec, installed_exec
end
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
assert_path_exists installed_exec
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
@@ -510,11 +546,13 @@ gem 'other', version
def test_generate_bin_symlink
return if win_platform? #Windows FS do not support symlinks
- @installer.wrappers = false
+ installer = setup_base_installer
+
+ installer.wrappers = false
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_equal true, File.symlink?(installed_exec)
@@ -523,18 +561,22 @@ gem 'other', version
end
def test_generate_bin_symlink_no_execs
- util_execless
+ installer = setup_base_installer
+
+ installer = util_execless
- @installer.wrappers = false
- @installer.generate_bin
+ installer.wrappers = false
+ installer.generate_bin
refute_path_exists util_inst_bindir
end
def test_generate_bin_symlink_no_perms
- @installer.wrappers = false
+ installer = setup_base_installer
+
+ installer.wrappers = false
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
Dir.mkdir util_inst_bindir
@@ -546,7 +588,7 @@ gem 'other', version
FileUtils.chmod 0000, util_inst_bindir
assert_raises Gem::FilePermissionError do
- @installer.generate_bin
+ installer.generate_bin
end
end
ensure
@@ -556,11 +598,13 @@ gem 'other', version
def test_generate_bin_symlink_update_newer
return if win_platform? #Windows FS do not support symlinks
- @installer.wrappers = false
+ installer = setup_base_installer
+
+ installer.wrappers = false
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
File.readlink(installed_exec))
@@ -575,8 +619,8 @@ gem 'other', version
end
util_make_exec
- @installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.gem_dir = @spec.gem_dir
+ installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(@spec.bin_file('executable'),
File.readlink(installed_exec),
@@ -586,11 +630,13 @@ gem 'other', version
def test_generate_bin_symlink_update_older
return if !symlink_supported?
- @installer.wrappers = false
+ installer = setup_base_installer
+
+ installer.wrappers = false
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join(util_inst_bindir, 'executable')
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
File.readlink(installed_exec))
@@ -607,10 +653,10 @@ gem 'other', version
util_make_exec
one = @spec.dup
one.version = 1
- @installer = Gem::Installer.for_spec spec
- @installer.gem_dir = one.gem_dir
+ installer = Gem::Installer.for_spec spec
+ installer.gem_dir = one.gem_dir
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
expected = File.join @spec.gem_dir, 'bin', 'executable'
@@ -622,11 +668,13 @@ gem 'other', version
def test_generate_bin_symlink_update_remove_wrapper
return if !symlink_supported?
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
@@ -642,10 +690,10 @@ gem 'other', version
util_make_exec
util_installer @spec, @gemhome
- @installer.wrappers = false
- @installer.gem_dir = @spec.gem_dir
+ installer.wrappers = false
+ installer.gem_dir = @spec.gem_dir
- @installer.generate_bin
+ installer.generate_bin
installed_exec = File.join util_inst_bindir, 'executable'
assert_equal(@spec.bin_file('executable'),
@@ -659,12 +707,15 @@ gem 'other', version
old_alt_separator = File::ALT_SEPARATOR
File.__send__(:remove_const, :ALT_SEPARATOR)
File.const_set(:ALT_SEPARATOR, '\\')
- @installer.wrappers = false
+
+ installer = setup_base_installer
+
+ installer.wrappers = false
util_make_exec
- @installer.gem_dir = @spec.gem_dir
+ installer.gem_dir = @spec.gem_dir
use_ui @ui do
- @installer.generate_bin
+ installer.generate_bin
end
assert_directory_exists util_inst_bindir
@@ -690,10 +741,12 @@ gem 'other', version
def test_generate_bin_uses_default_shebang
return if !symlink_supported?
- @installer.wrappers = true
+ installer = setup_base_installer
+
+ installer.wrappers = true
util_make_exec
- @installer.generate_bin
+ installer.generate_bin
default_shebang = Gem.ruby
shebang_line = open("#{@gemhome}/bin/executable") { |f| f.readlines.first }
@@ -719,6 +772,8 @@ gem 'other', version
end
def test_initialize_user_install
+ @gem = setup_base_gem
+
installer = Gem::Installer.at @gem, :user_install => true
assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name),
@@ -727,6 +782,8 @@ gem 'other', version
end
def test_initialize_user_install_bin_dir
+ @gem = setup_base_gem
+
installer =
Gem::Installer.at @gem, :user_install => true, :bin_dir => @tempdir
@@ -736,9 +793,7 @@ gem 'other', version
end
def test_install
- Dir.mkdir util_inst_bindir
- util_setup_gem
- util_clear_gems
+ installer = util_setup_installer
gemdir = File.join @gemhome, 'gems', @spec.full_name
cache_file = File.join @gemhome, 'cache', @spec.file_name
@@ -746,13 +801,13 @@ gem 'other', version
rakefile = File.join gemdir, 'ext', 'a', 'Rakefile'
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
- Gem.pre_install do |installer|
+ Gem.pre_install do
refute_path_exists cache_file, 'cache file must not exist yet'
refute_path_exists spec_file, 'spec file must not exist yet'
true
end
- Gem.post_build do |installer|
+ Gem.post_build do
assert_path_exists gemdir, 'gem install dir must exist'
assert_path_exists rakefile, 'gem executable must exist'
refute_path_exists stub_exe, 'gem executable must not exist'
@@ -760,7 +815,7 @@ gem 'other', version
true
end
- Gem.post_install do |installer|
+ Gem.post_install do
assert_path_exists cache_file, 'cache file must exist'
assert_path_exists spec_file, 'spec file must exist'
end
@@ -768,7 +823,7 @@ gem 'other', version
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -786,29 +841,25 @@ gem 'other', version
assert_path_exists rakefile
- spec_file = File.join(@gemhome, 'specifications', @spec.spec_name)
-
assert_equal spec_file, @newspec.loaded_from
assert_path_exists spec_file
- assert_same @installer, @post_build_hook_arg
- assert_same @installer, @post_install_hook_arg
- 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_creates_working_binstub
- Dir.mkdir util_inst_bindir
- util_setup_gem
- util_clear_gems
+ installer = util_setup_installer
- @installer.wrappers = true
+ installer.wrappers = true
gemdir = File.join @gemhome, 'gems', @spec.full_name
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -822,11 +873,10 @@ gem 'other', version
end
def test_conflicting_binstubs
- Dir.mkdir util_inst_bindir
- util_clear_gems
+ @gem = setup_base_gem
# build old version that has a bin file
- util_setup_gem do |spec|
+ installer = util_setup_gem do |spec|
File.open File.join('bin', 'executable'), 'w' do |f|
f.puts "require 'code'"
end
@@ -835,17 +885,17 @@ gem 'other', version
end
end
- @installer.wrappers = true
+ installer.wrappers = true
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
- old_bin_file = File.join @installer.bin_dir, 'executable'
+ old_bin_file = File.join installer.bin_dir, 'executable'
# build new version that doesn't have a bin file
- util_setup_gem do |spec|
+ installer = util_setup_gem do |spec|
FileUtils.rm File.join('bin', 'executable')
spec.files.delete File.join('bin', 'executable')
spec.executables.delete 'executable'
@@ -857,7 +907,7 @@ gem 'other', version
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -871,16 +921,14 @@ gem 'other', version
end
def test_install_creates_binstub_that_understand_version
- Dir.mkdir util_inst_bindir
- util_setup_gem
- util_clear_gems
+ installer = util_setup_installer
- @installer.wrappers = true
+ installer.wrappers = true
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -902,23 +950,21 @@ gem 'other', version
end
def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
- Dir.mkdir util_inst_bindir
-
install_default_gems new_default_spec('default', '2')
- util_setup_gem do |spec|
+ installer = util_setup_installer do |spec|
spec.name = 'default'
spec.version = '2'
end
util_clear_gems
- @installer.wrappers = true
+ installer.wrappers = true
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -932,16 +978,14 @@ gem 'other', version
end
def test_install_creates_binstub_that_dont_trust_encoding
- Dir.mkdir util_inst_bindir
- util_setup_gem
- util_clear_gems
+ installer = util_setup_installer
- @installer.wrappers = true
+ installer.wrappers = true
@newspec = nil
build_rake_in do
use_ui @ui do
- @newspec = @installer.install
+ @newspec = installer.install
end
end
@@ -964,20 +1008,19 @@ gem 'other', version
end
def test_install_with_no_prior_files
- Dir.mkdir util_inst_bindir
- util_clear_gems
+ installer = util_setup_installer
- util_setup_gem
build_rake_in do
use_ui @ui do
- assert_equal @spec, @installer.install
+ assert_equal @spec, installer.install
end
end
gemdir = File.join(@gemhome, 'gems', @spec.full_name)
assert_path_exists File.join gemdir, 'lib', 'code.rb'
- util_setup_gem
+ installer = util_setup_installer
+
# Morph spec to have lib/other.rb instead of code.rb and recreate
@spec.files = File.join('lib', 'other.rb')
Dir.chdir @tempdir do
@@ -990,10 +1033,10 @@ gem 'other', version
Gem::Package.build @spec
end
end
- @installer = Gem::Installer.at @gem
+ installer = Gem::Installer.at @gem
build_rake_in do
use_ui @ui do
- assert_equal @spec, @installer.install
+ assert_equal @spec, installer.install
end
end
@@ -1013,12 +1056,14 @@ gem 'other', version
end
def test_install_missing_dirs
+ installer = setup_base_installer
+
FileUtils.rm_f File.join(Gem.dir, 'cache')
FileUtils.rm_f File.join(Gem.dir, 'doc')
FileUtils.rm_f File.join(Gem.dir, 'specifications')
use_ui @ui do
- @installer.install
+ installer.install
end
assert_directory_exists File.join(Gem.dir, 'cache')
@@ -1030,7 +1075,7 @@ gem 'other', version
end
def test_install_post_build_false
- util_clear_gems
+ installer = setup_base_installer
Gem.post_build do
false
@@ -1038,7 +1083,7 @@ gem 'other', version
use_ui @ui do
e = assert_raises Gem::InstallError do
- @installer.install
+ installer.install
end
location = "#{__FILE__}:#{__LINE__ - 9}"
@@ -1054,14 +1099,14 @@ gem 'other', version
end
def test_install_post_build_nil
- util_clear_gems
+ installer = setup_base_installer
Gem.post_build do
nil
end
use_ui @ui do
- @installer.install
+ installer.install
end
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
@@ -1072,7 +1117,7 @@ gem 'other', version
end
def test_install_pre_install_false
- util_clear_gems
+ installer = setup_base_installer
Gem.pre_install do
false
@@ -1080,7 +1125,7 @@ gem 'other', version
use_ui @ui do
e = assert_raises Gem::InstallError do
- @installer.install
+ installer.install
end
location = "#{__FILE__}:#{__LINE__ - 9}"
@@ -1093,14 +1138,14 @@ gem 'other', version
end
def test_install_pre_install_nil
- util_clear_gems
+ installer = setup_base_installer
Gem.pre_install do
nil
end
use_ui @ui do
- @installer.install
+ installer.install
end
spec_file = File.join @gemhome, 'specifications', @spec.spec_name
@@ -1108,26 +1153,28 @@ gem 'other', version
end
def test_install_with_message
+ @spec = setup_base_spec
@spec.post_install_message = 'I am a shiny gem!'
use_ui @ui do
path = Gem::Package.build @spec
- @installer = Gem::Installer.at path
- @installer.install
+ installer = Gem::Installer.at path
+ installer.install
end
assert_match %r|I am a shiny gem!|, @ui.output
end
def test_install_with_skipped_message
+ @spec = setup_base_spec
@spec.post_install_message = 'I am a shiny gem!'
use_ui @ui do
path = Gem::Package.build @spec
- @installer = Gem::Installer.at path, :post_install_message => false
- @installer.install
+ installer = Gem::Installer.at path, :post_install_message => false
+ installer.install
end
refute_match %r|I am a shiny gem!|, @ui.output
@@ -1136,6 +1183,7 @@ gem 'other', version
def test_install_extension_dir
gemhome2 = "#{@gemhome}2"
+ @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1159,6 +1207,8 @@ gem 'other', version
end
def test_install_extension_dir_is_removed_on_reinstall
+ @spec = setup_base_spec
+
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1194,6 +1244,7 @@ gem 'other', version
end
def test_install_user_extension_dir
+ @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1223,6 +1274,9 @@ gem 'other', version
end
def test_find_lib_file_after_install
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
+
+ @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1266,6 +1320,9 @@ gem 'other', version
end
def test_install_extension_and_script
+ skip "Makefile creation crashes on jruby" if Gem.java_platform?
+
+ @spec = setup_base_spec
@spec.extensions << "extconf.rb"
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
@@ -1296,14 +1353,17 @@ gem 'other', version
use_ui @ui do
path = Gem::Package.build @spec
- @installer = Gem::Installer.at path
- @installer.install
+ installer = Gem::Installer.at path
+ installer.install
end
assert_path_exists File.join @spec.gem_dir, rb
assert_path_exists File.join @spec.gem_dir, rb2
end
def test_install_extension_flat
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
+
+ @spec = setup_base_spec
@spec.require_paths = ["."]
@spec.extensions << "extconf.rb"
@@ -1330,8 +1390,8 @@ gem 'other', version
use_ui @ui do
path = Gem::Package.build @spec
- @installer = Gem::Installer.at path
- @installer.install
+ installer = Gem::Installer.at path
+ installer.install
end
assert_path_exists so
rescue
@@ -1350,49 +1410,56 @@ gem 'other', version
end
def test_installation_satisfies_dependency_eh
+ installer = setup_base_installer
+
util_spec 'a'
dep = Gem::Dependency.new 'a', '>= 2'
- assert @installer.installation_satisfies_dependency?(dep)
+ assert installer.installation_satisfies_dependency?(dep)
dep = Gem::Dependency.new 'a', '> 2'
- refute @installer.installation_satisfies_dependency?(dep)
+ refute installer.installation_satisfies_dependency?(dep)
end
def test_installation_satisfies_dependency_eh_development
- @installer.options[:development] = true
- @installer.options[:dev_shallow] = true
+ installer = setup_base_installer
+ installer.options[:development] = true
+ installer.options[:dev_shallow] = true
util_spec 'a'
dep = Gem::Dependency.new 'a', :development
- assert @installer.installation_satisfies_dependency?(dep)
+ assert installer.installation_satisfies_dependency?(dep)
end
def test_pre_install_checks_dependencies
+ installer = setup_base_installer
@spec.add_dependency 'b', '> 5'
- util_setup_gem
+ installer = util_setup_gem
use_ui @ui do
assert_raises Gem::InstallError do
- @installer.install
+ installer.install
end
end
end
def test_pre_install_checks_dependencies_ignore
+ installer = util_setup_installer
@spec.add_dependency 'b', '> 5'
- @installer.ignore_dependencies = true
+ installer.ignore_dependencies = true
build_rake_in do
use_ui @ui do
- assert @installer.pre_install_checks
+ assert installer.pre_install_checks
end
end
end
def test_pre_install_checks_dependencies_install_dir
gemhome2 = "#{@gemhome}2"
+
+ @gem = setup_base_gem
@spec.add_dependency 'd'
quick_gem 'd', 2
@@ -1455,9 +1522,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::RuntimeRequirementNotMetError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
rgv = Gem::VERSION
assert_equal "old_rubygems_required requires RubyGems version < 0. The current RubyGems version is #{rgv}. " +
@@ -1477,9 +1544,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal '#<Gem::Specification name=../malicious version=1> has an invalid name', e.message
end
@@ -1497,9 +1564,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious\n::Object.const_set(:FROM_EVAL, true)# version=1> has an invalid name", e.message
end
@@ -1519,9 +1586,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid require_paths", e.message
end
@@ -1542,9 +1609,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid extensions", e.message
end
@@ -1563,9 +1630,9 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
+ installer = Gem::Installer.at gem
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid specification_version", e.message
end
@@ -1584,75 +1651,90 @@ gem 'other', version
gem = File.join(@gemhome, 'cache', spec.file_name)
use_ui @ui do
- @installer = Gem::Installer.at gem
- @installer.ignore_dependencies = true
+ installer = Gem::Installer.at gem
+ installer.ignore_dependencies = true
e = assert_raises Gem::InstallError do
- @installer.pre_install_checks
+ installer.pre_install_checks
end
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid dependencies", e.message
end
end
def test_shebang
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_process_options
- assert_nil @installer.build_root
- assert_equal File.join(@gemhome, 'bin'), @installer.bin_dir
- assert_equal @gemhome, @installer.gem_home
+ installer = setup_base_installer
+
+ assert_nil installer.build_root
+ assert_equal File.join(@gemhome, 'bin'), installer.bin_dir
+ assert_equal @gemhome, installer.gem_home
end
def test_process_options_build_root
build_root = File.join @tempdir, 'build_root'
- @installer = Gem::Installer.at @gem, :build_root => build_root
+ @gem = setup_base_gem
+ installer = Gem::Installer.at @gem, :build_root => build_root
- assert_equal Pathname(build_root), @installer.build_root
- assert_equal File.join(build_root, @gemhome, 'bin'), @installer.bin_dir
- assert_equal File.join(build_root, @gemhome), @installer.gem_home
+ assert_equal Pathname(build_root), installer.build_root
+ assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir
+ assert_equal File.join(build_root, @gemhome), installer.gem_home
end
def test_shebang_arguments
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/ruby -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_empty
+ installer = setup_base_installer
+
util_make_exec @spec, ''
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_env
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/env ruby"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_env_arguments
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/env ruby -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_env_shebang
+ installer = setup_base_installer
+
util_make_exec @spec, ''
- @installer.env_shebang = true
+ installer.env_shebang = true
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
env_shebang = "/usr/bin/env" unless Gem.win_platform?
@@ -1661,54 +1743,68 @@ gem 'other', version
end
def test_shebang_nested
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_nested_arguments
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_version
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/ruby18"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_version_arguments
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_version_env
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/env ruby18"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby}", shebang
end
def test_shebang_version_env_arguments
+ installer = setup_base_installer
+
util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!#{Gem.ruby} -ws", shebang
end
def test_shebang_custom
+ installer = setup_base_installer
+
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = 'test'
@@ -1716,12 +1812,14 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!test", shebang
end
def test_shebang_custom_with_expands
+ installer = setup_base_installer
+
bin_env = win_platform? ? '' : '/usr/bin/env'
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
@@ -1730,12 +1828,14 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang
end
def test_shebang_custom_with_expands_and_arguments
+ installer = setup_base_installer
+
bin_env = win_platform? ? '' : '/usr/bin/env'
conf = Gem::ConfigFile.new []
conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
@@ -1744,18 +1844,18 @@ gem 'other', version
util_make_exec @spec, "#!/usr/bin/ruby -ws"
- shebang = @installer.shebang 'executable'
+ shebang = installer.shebang 'executable'
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang
end
def test_unpack
- util_setup_gem
+ installer = util_setup_installer
dest = File.join @gemhome, 'gems', @spec.full_name
Gem::Deprecate.skip_during do
- @installer.unpack dest
+ installer.unpack dest
end
assert_path_exists File.join dest, 'lib', 'code.rb'
@@ -1763,13 +1863,15 @@ gem 'other', version
end
def test_write_build_info_file
+ installer = setup_base_installer
+
refute_path_exists @spec.build_info_file
- @installer.build_args = %w[
+ installer.build_args = %w[
--with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
]
- @installer.write_build_info_file
+ installer.write_build_info_file
assert_path_exists @spec.build_info_file
@@ -1779,14 +1881,17 @@ gem 'other', version
end
def test_write_build_info_file_empty
+ installer = setup_base_installer
+
refute_path_exists @spec.build_info_file
- @installer.write_build_info_file
+ installer.write_build_info_file
refute_path_exists @spec.build_info_file
end
def test_write_build_info_file_install_dir
+ @gem = setup_base_gem
installer = Gem::Installer.at @gem, :install_dir => "#{@gemhome}2"
installer.build_args = %w[
@@ -1801,6 +1906,7 @@ gem 'other', version
end
def test_write_cache_file
+ @gem = setup_base_gem
cache_file = File.join @gemhome, 'cache', @spec.file_name
gem = File.join @gemhome, @spec.file_name
@@ -1816,13 +1922,14 @@ gem 'other', version
end
def test_write_spec
+ @spec = setup_base_spec
FileUtils.rm @spec.spec_file
refute_path_exists @spec.spec_file
- @installer = Gem::Installer.for_spec @spec
- @installer.gem_home = @gemhome
+ installer = Gem::Installer.for_spec @spec
+ installer.gem_home = @gemhome
- @installer.write_spec
+ installer.write_spec
assert_path_exists @spec.spec_file
@@ -1834,15 +1941,16 @@ gem 'other', version
end
def test_write_spec_writes_cached_spec
+ @spec = setup_base_spec
FileUtils.rm @spec.spec_file
refute_path_exists @spec.spec_file
@spec.files = %w[a.rb b.rb c.rb]
- @installer = Gem::Installer.for_spec @spec
- @installer.gem_home = @gemhome
+ installer = Gem::Installer.for_spec @spec
+ installer.gem_home = @gemhome
- @installer.write_spec
+ installer.write_spec
# cached specs have no file manifest:
@spec.files = []
@@ -1851,7 +1959,9 @@ gem 'other', version
end
def test_dir
- assert_match %r!/gemhome/gems/a-2$!, @installer.dir
+ installer = setup_base_installer
+
+ assert_match %r!/gemhome/gems/a-2$!, installer.dir
end
def test_default_gem_loaded_from
@@ -1862,14 +1972,16 @@ gem 'other', version
end
def test_default_gem_without_wrappers
+ installer = setup_base_installer
+
FileUtils.rm_f File.join(Gem.dir, 'specifications')
- @installer.wrappers = false
- @installer.options[:install_as_default] = true
- @installer.gem_dir = @spec.gem_dir
+ installer.wrappers = false
+ installer.options[:install_as_default] = true
+ installer.gem_dir = @spec.gem_dir
use_ui @ui do
- @installer.install
+ installer.install
end
assert_directory_exists File.join(@spec.gem_dir, 'bin')
@@ -1893,14 +2005,14 @@ gem 'other', version
end
def test_default_gem_with_wrappers
- FileUtils.rm_f File.join(Gem.dir, 'specifications')
+ installer = setup_base_installer
- @installer.wrappers = true
- @installer.options[:install_as_default] = true
- @installer.gem_dir = @spec.gem_dir
+ installer.wrappers = true
+ installer.options[:install_as_default] = true
+ installer.gem_dir = @spec.gem_dir
use_ui @ui do
- @installer.install
+ installer.install
end
assert_directory_exists util_inst_bindir
@@ -1913,8 +2025,6 @@ gem 'other', version
end
def test_default_gem_with_exe_as_bindir
- FileUtils.rm_f File.join(Gem.dir, 'specifications')
-
@spec = quick_gem 'c' do |spec|
util_make_exec spec, '#!/usr/bin/ruby', 'exe'
end
@@ -1958,7 +2068,7 @@ gem 'other', version
@spec = util_spec 'z'
util_build_gem @spec
- @installer = util_installer @spec, @gemhome
+ util_installer @spec, @gemhome
end
def util_conflict_executable(wrappers)
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 03accc9dfe..cedd2f5e55 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -2,7 +2,6 @@
# frozen_string_literal: true
require 'rubygems/package/tar_test_case'
-require 'rubygems/simple_gem'
class TestGemPackage < Gem::Package::TarTestCase
@@ -24,6 +23,8 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_class_new_old_format
+ skip "jruby can't require the simple_gem file" if Gem.java_platform?
+ require_relative "simple_gem"
File.open 'old_format.gem', 'wb' do |io|
io.write SIMPLE_GEM
end
@@ -839,6 +840,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_corrupt
+ skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
tf = Tempfile.open 'corrupt' do |io|
data = Gem::Util.gzip 'a' * 10
io.write \
diff --git a/test/rubygems/test_gem_package_old.rb b/test/rubygems/test_gem_package_old.rb
index ab7934dde5..d2ce59cfdd 100644
--- a/test/rubygems/test_gem_package_old.rb
+++ b/test/rubygems/test_gem_package_old.rb
@@ -1,89 +1,92 @@
# frozen_string_literal: true
require 'rubygems/test_case'
-require 'rubygems/simple_gem'
-class TestGemPackageOld < Gem::TestCase
+unless Gem.java_platform? # jruby can't require the simple_gem file
+ require 'rubygems/simple_gem'
- def setup
- super
+ class TestGemPackageOld < Gem::TestCase
- File.open 'old_format.gem', 'wb' do |io|
- io.write SIMPLE_GEM
- end
+ def setup
+ super
- @package = Gem::Package::Old.new 'old_format.gem'
- @destination = File.join @tempdir, 'extract'
+ File.open 'old_format.gem', 'wb' do |io|
+ io.write SIMPLE_GEM
+ end
- FileUtils.mkdir_p @destination
- end
+ @package = Gem::Package::Old.new 'old_format.gem'
+ @destination = File.join @tempdir, 'extract'
- def test_contents
- assert_equal %w[lib/foo.rb lib/test.rb lib/test/wow.rb], @package.contents
- end
+ FileUtils.mkdir_p @destination
+ end
- def test_contents_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_contents
+ assert_equal %w[lib/foo.rb lib/test.rb lib/test/wow.rb], @package.contents
+ end
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ def test_contents_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- assert_raises Gem::Security::Exception do
- @package.contents
+ @package.security_policy = Gem::Security::AlmostNoSecurity
+
+ assert_raises Gem::Security::Exception do
+ @package.contents
+ end
end
- end
- def test_extract_files
- @package.extract_files @destination
+ def test_extract_files
+ @package.extract_files @destination
- extracted = File.join @destination, 'lib/foo.rb'
- assert_path_exists extracted
+ extracted = File.join @destination, 'lib/foo.rb'
+ assert_path_exists extracted
- mask = 0100644 & (~File.umask)
+ mask = 0100644 & (~File.umask)
- assert_equal mask, File.stat(extracted).mode unless win_platform?
- end
+ assert_equal mask, File.stat(extracted).mode unless win_platform?
+ end
- def test_extract_files_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_extract_files_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_raises Gem::Security::Exception do
- @package.extract_files @destination
+ assert_raises Gem::Security::Exception do
+ @package.extract_files @destination
+ end
end
- end
- def test_spec
- assert_equal 'testing', @package.spec.name
- end
+ def test_spec
+ assert_equal 'testing', @package.spec.name
+ end
- def test_spec_security_policy
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_spec_security_policy
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- assert_raises Gem::Security::Exception do
- @package.spec
+ assert_raises Gem::Security::Exception do
+ @package.spec
+ end
end
- end
- def test_verify
- skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ def test_verify
+ skip 'openssl is missing' unless defined?(OpenSSL::SSL)
- assert @package.verify
+ assert @package.verify
- @package.security_policy = Gem::Security::NoSecurity
+ @package.security_policy = Gem::Security::NoSecurity
- assert @package.verify
+ assert @package.verify
- @package.security_policy = Gem::Security::AlmostNoSecurity
+ @package.security_policy = Gem::Security::AlmostNoSecurity
- e = assert_raises Gem::Security::Exception do
- @package.verify
+ e = assert_raises Gem::Security::Exception do
+ @package.verify
+ end
+
+ assert_equal 'old format gems do not contain signatures ' +
+ 'and cannot be verified',
+ e.message
end
- assert_equal 'old format gems do not contain signatures ' +
- 'and cannot be verified',
- e.message
end
-
end
diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb
index 5e804bb418..7e59073407 100644
--- a/test/rubygems/test_gem_package_tar_header.rb
+++ b/test/rubygems/test_gem_package_tar_header.rb
@@ -164,4 +164,45 @@ group\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
end
end
+ def test_big_uid_gid
+ stream = StringIO.new(
+ <<-EOF.dup.force_encoding('binary').split("\n").join
+GeoIP2-City_20190528/
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000755\x00\x80\x00
+\x00\x00v\xB2Z\x9E\x80\x00\x00\x00v\xB2Z\x9E00000000000\x0013473270100\x00015424
+\x00 5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ustar \x00
+tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
+\x00\x00\x00\x00
+ EOF
+ )
+
+ tar_header = Gem::Package::TarHeader.from stream
+
+ assert_equal 1991400094, tar_header.uid
+ assert_equal 1991400094, tar_header.gid
+
+ assert_equal 'GeoIP2-City_20190528/', tar_header.name
+ assert_equal 0755, tar_header.mode
+ assert_equal 0, tar_header.size
+ assert_equal 1559064640, tar_header.mtime
+ assert_equal 6932, tar_header.checksum
+ end
+
end
diff --git a/test/rubygems/test_gem_package_tar_reader_entry.rb b/test/rubygems/test_gem_package_tar_reader_entry.rb
index 4627c230d9..87f3471678 100644
--- a/test/rubygems/test_gem_package_tar_reader_entry.rb
+++ b/test/rubygems/test_gem_package_tar_reader_entry.rb
@@ -76,6 +76,7 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
end
def test_full_name_null
+ skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
@entry.header.prefix << "\000"
e = assert_raises Gem::Package::TarInvalidError do
diff --git a/test/rubygems/test_gem_path_support.rb b/test/rubygems/test_gem_path_support.rb
index 1f9cfe2c57..8715bb62dc 100644
--- a/test/rubygems/test_gem_path_support.rb
+++ b/test/rubygems/test_gem_path_support.rb
@@ -40,17 +40,19 @@ class TestGemPathSupport < Gem::TestCase
end
def test_initialize_path
- ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
+ Gem.stub(:path_separator, File::PATH_SEPARATOR) do
+ ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
- assert_equal ENV["GEM_HOME"], ps.home
+ assert_equal ENV["GEM_HOME"], ps.home
- expected = [
- File.join(@tempdir, 'foo'),
- File.join(@tempdir, 'bar'),
- ENV["GEM_HOME"],
- ]
+ expected = [
+ File.join(@tempdir, 'foo'),
+ File.join(@tempdir, 'bar'),
+ ENV["GEM_HOME"],
+ ]
- assert_equal expected, ps.path
+ assert_equal expected, ps.path
+ end
end
def test_initialize_regexp_path_separator
@@ -90,13 +92,15 @@ class TestGemPathSupport < Gem::TestCase
end
def test_initialize_home_path
- ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
- "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
+ Gem.stub(:path_separator, File::PATH_SEPARATOR) do
+ ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
+ "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))
- assert_equal File.join(@tempdir, "foo"), ps.home
+ assert_equal File.join(@tempdir, "foo"), ps.home
- expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
- assert_equal expected, ps.path
+ expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
+ assert_equal expected, ps.path
+ end
end
def util_path
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index e21ece2f50..7d5bcc23a9 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -785,6 +785,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_ssl_client_cert_auth_connection
skip 'openssl is missing' unless defined?(OpenSSL::SSL)
+ skip 'openssl in jruby fails' if java_platform?
ssl_server = self.class.start_ssl_server({
:SSLVerifyClient =>
@@ -1050,12 +1051,4 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
- def test_correct_for_windows_path
- path = "/C:/WINDOWS/Temp/gems"
- assert_equal "C:/WINDOWS/Temp/gems", @fetcher.correct_for_windows_path(path)
-
- path = "/home/skillet"
- assert_equal "/home/skillet", @fetcher.correct_for_windows_path(path)
- end
-
end if defined?(OpenSSL::SSL)
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
index 5f7d7bb7be..b9601b7c2c 100644
--- a/test/rubygems/test_gem_request.rb
+++ b/test/rubygems/test_gem_request.rb
@@ -328,6 +328,7 @@ class TestGemRequest < Gem::TestCase
end
def test_verify_certificate
+ skip if Gem.java_platform?
store = OpenSSL::X509::Store.new
context = OpenSSL::X509::StoreContext.new store
context.error = OpenSSL::X509::V_ERR_OUT_OF_MEM
@@ -341,6 +342,7 @@ class TestGemRequest < Gem::TestCase
end
def test_verify_certificate_extra_message
+ skip if Gem.java_platform?
store = OpenSSL::X509::Store.new
context = OpenSSL::X509::StoreContext.new store
context.error = OpenSSL::X509::V_ERR_INVALID_CA
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index 0df0bef215..24cfb67c4d 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -856,4 +856,4 @@ end
engine
end
-end
+end unless Gem.java_platform?
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index 4f88f83e16..172b46a33d 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -97,7 +97,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new a1, r1, false
+ act = Gem::Resolver::ActivationRequest.new a1, r1
res = Gem::Resolver.new [a1]
@@ -118,7 +118,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new spec, r1, false
+ act = Gem::Resolver::ActivationRequest.new spec, r1
res = Gem::Resolver.new [act]
res.development = true
@@ -137,7 +137,7 @@ class TestGemResolver < Gem::TestCase
r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil
- act = Gem::Resolver::ActivationRequest.new a1, r1, false
+ act = Gem::Resolver::ActivationRequest.new a1, r1
res = Gem::Resolver.new [a1]
res.ignore_dependencies = true
diff --git a/test/rubygems/test_gem_resolver_activation_request.rb b/test/rubygems/test_gem_resolver_activation_request.rb
index 5d5de1a2d5..dc11ad47c4 100644
--- a/test/rubygems/test_gem_resolver_activation_request.rb
+++ b/test/rubygems/test_gem_resolver_activation_request.rb
@@ -13,11 +13,9 @@ class TestGemResolverActivationRequest < Gem::TestCase
source = Gem::Source::Local.new
platform = Gem::Platform::RUBY
- @a1 = @DR::IndexSpecification.new nil, 'a', v(1), source, platform
- @a2 = @DR::IndexSpecification.new nil, 'a', v(2), source, platform
@a3 = @DR::IndexSpecification.new nil, 'a', v(3), source, platform
- @req = @DR::ActivationRequest.new @a3, @dep, [@a1, @a2]
+ @req = @DR::ActivationRequest.new @a3, @dep
end
def test_development_eh
@@ -25,7 +23,7 @@ class TestGemResolverActivationRequest < Gem::TestCase
dep_req = @DR::DependencyRequest.new dep('a', '>= 0', :development), nil
- act_req = @DR::ActivationRequest.new @a3, dep_req, [@a1, @a2]
+ act_req = @DR::ActivationRequest.new @a3, dep_req
assert act_req.development?
end
@@ -33,41 +31,14 @@ class TestGemResolverActivationRequest < Gem::TestCase
def test_inspect
assert_match 'a-3', @req.inspect
assert_match 'from a (>= 0)', @req.inspect
- assert_match '(others possible: a-1, a-2)', @req.inspect
- end
-
- def test_inspect_legacy
- req = @DR::ActivationRequest.new @a3, @dep, true
-
- assert_match '(others possible)', req.inspect
-
- req = @DR::ActivationRequest.new @a3, @dep, false
-
- refute_match '(others possible)', req.inspect
end
def test_installed_eh
v_spec = Gem::Resolver::VendorSpecification.new nil, @a3
- @req = @DR::ActivationRequest.new v_spec, @dep, [@a1, @a2]
+ @req = @DR::ActivationRequest.new v_spec, @dep
assert @req.installed?
end
- def test_others_possible_eh
- assert @req.others_possible?
-
- req = @DR::ActivationRequest.new @a3, @dep, []
-
- refute req.others_possible?
-
- req = @DR::ActivationRequest.new @a3, @dep, true
-
- assert req.others_possible?
-
- req = @DR::ActivationRequest.new @a3, @dep, false
-
- refute req.others_possible?
- end
-
end
diff --git a/test/rubygems/test_gem_resolver_git_specification.rb b/test/rubygems/test_gem_resolver_git_specification.rb
index 3a9bb6a802..3391505555 100644
--- a/test/rubygems/test_gem_resolver_git_specification.rb
+++ b/test/rubygems/test_gem_resolver_git_specification.rb
@@ -63,6 +63,7 @@ class TestGemResolverGitSpecification < Gem::TestCase
# functional test for Gem::Ext::Builder
def test_install_extension
+ skip if Gem.java_platform?
name, _, repository, = git_gem 'a', 1 do |s|
s.extensions << 'ext/extconf.rb'
end
diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb
index 1ba3fa7d9c..71185dc86e 100644
--- a/test/rubygems/test_gem_security.rb
+++ b/test/rubygems/test_gem_security.rb
@@ -6,6 +6,10 @@ unless defined?(OpenSSL::SSL)
warn 'Skipping Gem::Security tests. openssl not found.'
end
+if Gem.java_platform?
+ warn 'Skipping Gem::Security tests on jruby.'
+end
+
class TestGemSecurity < Gem::TestCase
CHILD_KEY = load_key 'child'
@@ -307,4 +311,4 @@ class TestGemSecurity < Gem::TestCase
assert_equal key.to_pem, key_from_file.to_pem
end
-end if defined?(OpenSSL::SSL)
+end if defined?(OpenSSL::SSL) && !Gem.java_platform?
diff --git a/test/rubygems/test_gem_security_signer.rb b/test/rubygems/test_gem_security_signer.rb
index 631afa87c4..08e74e6276 100644
--- a/test/rubygems/test_gem_security_signer.rb
+++ b/test/rubygems/test_gem_security_signer.rb
@@ -143,6 +143,7 @@ toqvglr0kdbknSRRjBVLK6tsgr07aLT9gNP7mTW2PA==
end
def test_sign_expired_auto_update
+ skip if Gem.java_platform?
FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700
private_key_path = File.join(Gem.user_home, '.gem', 'gem-private_key.pem')
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
index 2dafcacc8e..22fbdee05e 100644
--- a/test/rubygems/test_gem_source_git.rb
+++ b/test/rubygems/test_gem_source_git.rb
@@ -236,11 +236,6 @@ class TestGemSourceGit < Gem::TestCase
system @git, 'add', 'b.gemspec'
system @git, 'commit', '--quiet', '-m', 'add b/b.gemspec'
end
-
- FileUtils.touch 'c.gemspec'
-
- system @git, 'add', 'c.gemspec'
- system @git, 'commit', '--quiet', '-m', 'add c.gemspec'
end
specs = nil
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 5024cfbc52..4d3fb93ff1 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1441,6 +1441,7 @@ dependencies: []
end
def test_build_args
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert_empty @ext.build_args
@@ -1459,6 +1460,7 @@ dependencies: []
end
def test_build_extensions
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_path_exists @ext.extension_dir, 'sanity check'
@@ -1494,6 +1496,7 @@ dependencies: []
end
def test_build_extensions_built
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@@ -1532,6 +1535,7 @@ dependencies: []
end
def test_build_extensions_error
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@@ -1545,6 +1549,7 @@ dependencies: []
skip 'chmod not supported' if Gem.win_platform?
skip 'skipped in root privilege' if Process.uid.zero?
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@@ -1569,7 +1574,7 @@ dependencies: []
@ext.build_extensions
refute_path_exists @ext.extension_dir
ensure
- unless ($DEBUG or win_platform? or Process.uid.zero?)
+ unless ($DEBUG or win_platform? or Process.uid.zero? or Gem.java_platform?)
FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions')
FileUtils.chmod 0755, @ext.base_dir
end
@@ -1577,7 +1582,7 @@ dependencies: []
def test_build_extensions_no_extensions_dir_unwritable
skip 'chmod not supported' if Gem.win_platform?
-
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@@ -1616,6 +1621,7 @@ dependencies: []
end
def test_build_extensions_old
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@@ -1629,6 +1635,7 @@ dependencies: []
end
def test_build_extensions_preview
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
@@ -1663,6 +1670,7 @@ dependencies: []
end
def test_contains_requirable_file_eh_extension
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
_, err = capture_io do
@@ -3623,6 +3631,7 @@ end
end
def test_missing_extensions_eh
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert @ext.missing_extensions?
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index 10f8c04a0e..8553194c44 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -67,6 +67,7 @@ class TestStubSpecification < Gem::TestCase
end
def test_contains_requirable_file_eh_extension
+ skip "I guess making the stub match the running platform should work" if Gem.java_platform?
stub_with_extension do |stub|
_, err = capture_io do
refute stub.contains_requirable_file? 'nonexistent'
@@ -123,6 +124,7 @@ class TestStubSpecification < Gem::TestCase
end
def test_missing_extensions_eh
+ skip "I guess making the stub match the running platform should work" if Gem.java_platform?
stub = stub_with_extension do |s|
extconf_rb = File.join s.gem_dir, s.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
index 7440ca0191..9dfef7cfda 100644
--- a/test/rubygems/test_gem_uninstaller.rb
+++ b/test/rubygems/test_gem_uninstaller.rb
@@ -6,6 +6,8 @@ class TestGemUninstaller < Gem::InstallerTestCase
def setup
super
+ @installer = setup_base_installer
+ @user_installer = setup_base_user_installer
common_installer_setup
build_rake_in do
diff --git a/test/rubygems/test_gem_util.rb b/test/rubygems/test_gem_util.rb
index a48d275d28..3f1d069a20 100644
--- a/test/rubygems/test_gem_util.rb
+++ b/test/rubygems/test_gem_util.rb
@@ -5,6 +5,7 @@ require 'rubygems/util'
class TestGemUtil < Gem::TestCase
def test_class_popen
+ skip "popen with a block does not behave well on jruby" if Gem.java_platform?
assert_equal "0\n", Gem::Util.popen(Gem.ruby, '-I', File.expand_path('../../../lib', __FILE__), '-e', 'p 0')
assert_raises Errno::ECHILD do
@@ -13,6 +14,7 @@ class TestGemUtil < Gem::TestCase
end
def test_silent_system
+ skip if Gem.java_platform?
assert_silent do
Gem::Util.silent_system Gem.ruby, '-I', File.expand_path('../../../lib', __FILE__), '-e', 'puts "hello"; warn "hello"'
end
@@ -30,7 +32,7 @@ class TestGemUtil < Gem::TestCase
end
def test_traverse_parents_does_not_crash_on_permissions_error
- skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
+ skip 'skipped on MS Windows (chmod has no effect)' if win_platform? || java_platform?
FileUtils.mkdir_p 'd/e/f'
# remove 'execute' permission from "e" directory and make it
@@ -47,7 +49,7 @@ class TestGemUtil < Gem::TestCase
assert_equal File.realpath("..", Dir.tmpdir), paths[3]
ensure
# restore default permissions, allow the directory to be removed
- FileUtils.chmod(0775, 'd/e') unless win_platform?
+ FileUtils.chmod(0775, 'd/e') unless win_platform? || java_platform?
end
def test_linked_list_find
@@ -75,4 +77,12 @@ class TestGemUtil < Gem::TestCase
assert_equal expected_paths.to_set, files_with_relative_base.to_set
end
+ def test_correct_for_windows_path
+ path = "/C:/WINDOWS/Temp/gems"
+ assert_equal "C:/WINDOWS/Temp/gems", Gem::Util.correct_for_windows_path(path)
+
+ path = "/home/skillet"
+ assert_equal "/home/skillet", Gem::Util.correct_for_windows_path(path)
+ end
+
end
diff --git a/test/rubygems/test_gem_validator.rb b/test/rubygems/test_gem_validator.rb
index b9f597b7d3..34b7e5fb37 100644
--- a/test/rubygems/test_gem_validator.rb
+++ b/test/rubygems/test_gem_validator.rb
@@ -1,14 +1,13 @@
# frozen_string_literal: true
-require 'rubygems/test_case'
-require "rubygems/simple_gem"
-require 'rubygems/validator'
+
+require "rubygems/test_case"
+require "rubygems/validator"
class TestGemValidator < Gem::TestCase
def setup
super
- @simple_gem = SIMPLE_GEM
@validator = Gem::Validator.new
end
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 678dde2cae..7c86748a87 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -162,6 +162,10 @@ class TestGemRequire < Gem::TestCase
end
def test_activate_via_require_respects_loaded_files
+ skip "Not sure what's going on. If another spec creates a 'a' gem before
+ this test, somehow require will load the benchmark in b, and ignore that the
+ stdlib one is already in $LOADED_FEATURES?. Reproducible by running the
+ spaceship_specific_file test before this one" if java_platform?
a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
b2 = util_spec "b", "2", nil, "lib/benchmark.rb"
@@ -431,7 +435,8 @@ class TestGemRequire < Gem::TestCase
end
end
- if RUBY_VERSION >= "2.5"
+ # uplevel is 2.5+ only and jruby has some issues with it
+ if RUBY_VERSION >= "2.5" && !java_platform?
def test_no_kernel_require_in_warn_with_uplevel
lib = File.realpath("../../../lib", __FILE__)
Dir.mktmpdir("warn_test") do |dir|