aboutsummaryrefslogtreecommitdiffstats
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
parent560cd5b1f04f30542a294b3d77527d3b12f7cc15 (diff)
downloadruby-56660de3c6df7a4ff8667ef4047d30d0de169935.tar.gz
Merge rubygems master from upstream.
I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
-rw-r--r--lib/rubygems.rb24
-rw-r--r--lib/rubygems/commands/pristine_command.rb2
-rw-r--r--lib/rubygems/commands/query_command.rb170
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb4
-rw-r--r--lib/rubygems/core_ext/kernel_gem.rb3
-rw-r--r--lib/rubygems/defaults.rb7
-rw-r--r--lib/rubygems/ext/rake_builder.rb2
-rw-r--r--lib/rubygems/installer_test_case.rb116
-rw-r--r--lib/rubygems/package/tar_header.rb13
-rw-r--r--lib/rubygems/remote_fetcher.rb12
-rw-r--r--lib/rubygems/request/connection_pools.rb4
-rw-r--r--lib/rubygems/resolver.rb2
-rw-r--r--lib/rubygems/resolver/activation_request.rb49
-rw-r--r--lib/rubygems/specification.rb18
-rw-r--r--lib/rubygems/test_case.rb243
-rw-r--r--lib/rubygems/test_utilities.rb7
-rw-r--r--lib/rubygems/util.rb54
-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
55 files changed, 1024 insertions, 1026 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 193e8d3539..c013e4b8ed 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -670,6 +670,21 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
index
end
+ ##
+ # Add a list of paths to the $LOAD_PATH at the proper place.
+
+ def self.add_to_load_path(*paths)
+ insert_index = load_path_insert_index
+
+ if insert_index
+ # gem directories must come after -I and ENV['RUBYLIB']
+ $LOAD_PATH.insert(insert_index, *paths)
+ else
+ # we are probably testing in core, -I and RUBYLIB don't apply
+ $LOAD_PATH.unshift(*paths)
+ end
+ end
+
@yaml_loaded = false
##
@@ -1084,6 +1099,13 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
+ # Is this a java platform?
+
+ def self.java_platform?
+ RUBY_PLATFORM == "java"
+ end
+
+ ##
# Load +plugins+ as Ruby files
def self.load_plugin_files(plugins) # :nodoc:
@@ -1243,7 +1265,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
#
def register_default_spec(spec)
- new_format = Gem.default_gems_use_full_paths? || spec.require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
+ new_format = spec.require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
if new_format
prefix_group = spec.require_paths.map {|f| f + "/"}.join("|")
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index a25b690afc..e4628bdd40 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -104,7 +104,7 @@ extensions will be restored.
end.flatten
end
- specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform }
+ specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
if specs.to_a.empty?
raise Gem::Exception,
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 5a42d45249..4fb23bc6c1 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -78,46 +78,58 @@ is too hard to use.
end
def execute
+ gem_names = Array(options[:name])
+
+ if !args.empty?
+ gem_names = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
+ end
+
+ terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?
+
+ gem_names.each { |n| show_gems(n) }
+ end
+
+ private
+
+ def check_installed_gems(gem_names)
exit_code = 0
- if options[:args].to_a.empty? and options[:name].source.empty?
- name = options[:name]
- no_name = true
- elsif !options[:name].source.empty?
- name = Array(options[:name])
+
+ if args.empty? && !gem_name?
+ alert_error "You must specify a gem name"
+ exit_code = 4
+ elsif gem_names.count > 1
+ alert_error "You must specify only ONE gem!"
+ exit_code = 4
else
- args = options[:args].to_a
- name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
+ installed = installed?(gem_names.first, options[:version])
+ installed = !installed unless options[:installed]
+
+ say(installed)
+ exit_code = 1 if !installed
end
- prerelease = options[:prerelease]
+ exit_code
+ end
- unless options[:installed].nil?
- if no_name
- alert_error "You must specify a gem name"
- exit_code |= 4
- elsif name.count > 1
- alert_error "You must specify only ONE gem!"
- exit_code |= 4
- else
- installed = installed? name.first, options[:version]
- installed = !installed unless options[:installed]
+ def check_installed_gems?
+ !options[:installed].nil?
+ end
- if installed
- say "true"
- else
- say "false"
- exit_code |= 1
- end
- end
+ def gem_name?
+ !options[:name].source.empty?
+ end
- terminate_interaction exit_code
- end
+ def prerelease
+ options[:prerelease]
+ end
- names = Array(name)
- names.each { |n| show_gems n, prerelease }
+ def show_prereleases?
+ prerelease.nil? || prerelease
end
- private
+ def args
+ options[:args].to_a
+ end
def display_header(type)
if (ui.outs.tty? and Gem.configuration.verbose) or both?
@@ -128,56 +140,57 @@ is too hard to use.
end
#Guts of original execute
- def show_gems(name, prerelease)
- req = Gem::Requirement.default
- # TODO: deprecate for real
+ def show_gems(name)
+ show_local_gems(name) if local?
+ show_remote_gems(name) if remote?
+ end
+
+ def show_local_gems(name, req = Gem::Requirement.default)
+ display_header("LOCAL")
+
+ specs = Gem::Specification.find_all do |s|
+ s.name =~ name and req =~ s.version
+ end
+
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
- dep.prerelease = prerelease
+ specs.select! do |s|
+ dep.match?(s.name, s.version, show_prereleases?)
+ end
- if local?
- if prerelease and not both?
- alert_warning "prereleases are always shown locally"
- end
+ spec_tuples = specs.map do |spec|
+ [spec.name_tuple, spec]
+ end
+
+ output_query_results(spec_tuples)
+ end
- display_header 'LOCAL'
+ def show_remote_gems(name)
+ display_header("REMOTE")
- specs = Gem::Specification.find_all do |s|
- s.name =~ name and req =~ s.version
- end
+ fetcher = Gem::SpecFetcher.fetcher
- spec_tuples = specs.map do |spec|
- [spec.name_tuple, spec]
- end
+ spec_tuples = if name.respond_to?(:source) && name.source.empty?
+ fetcher.detect(specs_type) { true }
+ else
+ fetcher.detect(specs_type) do |name_tuple|
+ name === name_tuple.name
+ end
+ end
- output_query_results spec_tuples
- end
+ output_query_results(spec_tuples)
+ end
- if remote?
- display_header 'REMOTE'
-
- fetcher = Gem::SpecFetcher.fetcher
-
- type = if options[:all]
- if options[:prerelease]
- :complete
- else
- :released
- end
- elsif options[:prerelease]
- :prerelease
- else
- :latest
- end
-
- if name.respond_to?(:source) && name.source.empty?
- spec_tuples = fetcher.detect(type) { true }
+ def specs_type
+ if options[:all]
+ if options[:prerelease]
+ :complete
else
- spec_tuples = fetcher.detect(type) do |name_tuple|
- name === name_tuple.name
- end
+ :released
end
-
- output_query_results spec_tuples
+ elsif options[:prerelease]
+ :prerelease
+ else
+ :latest
end
end
@@ -235,7 +248,7 @@ is too hard to use.
name_tuple, spec = detail_tuple
- spec = spec.fetch_spec name_tuple if spec.respond_to? :fetch_spec
+ spec = spec.fetch_spec(name_tuple)if spec.respond_to?(:fetch_spec)
entry << "\n"
@@ -285,8 +298,8 @@ is too hard to use.
entry = [name_tuples.first.name]
- entry_versions entry, name_tuples, platforms, specs
- entry_details entry, detail_tuple, specs, platforms
+ entry_versions(entry, name_tuples, platforms, specs)
+ entry_details(entry, detail_tuple, specs, platforms)
entry.join
end
@@ -337,12 +350,13 @@ is too hard to use.
if platforms.length == 1
title = platforms.values.length == 1 ? 'Platform' : 'Platforms'
- entry << " #{title}: #{platforms.values.sort.join ', '}\n"
+ entry << " #{title}: #{platforms.values.sort.join(', ')}\n"
else
entry << " Platforms:\n"
- platforms.sort_by do |version,|
- version
- end.each do |version, pls|
+
+ sorted_platforms = platforms.sort_by { |version,| version }
+
+ sorted_platforms.each do |version, pls|
label = " #{version}: "
data = format_text pls.sort.join(', '), 68, label.length
data[0, label.length] = label
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index f5e5236a06..1754630c8c 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -429,7 +429,7 @@ By default, this RubyGems will install gem as:
Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec)
begin
- installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], install_as_default: true, bin_dir: bin_dir, wrappers: true)
+ installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], install_as_default: true, bin_dir: bin_dir, wrappers: true)
installer.install
ensure
FileUtils.rm_f built_gem
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 4b182396f3..e8031a259d 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -254,9 +254,7 @@ command to remove old versions.
def update_rubygems_arguments # :nodoc:
args = []
args << '--prefix' << Gem.prefix if Gem.prefix
- # TODO use --document for >= 1.9 , --no-rdoc --no-ri < 1.9
- args << '--no-rdoc' unless options[:document].include? 'rdoc'
- args << '--no-ri' unless options[:document].include? 'ri'
+ args << '--no-document' unless options[:document].include?('rdoc') || options[:document].include?('ri')
args << '--no-format-executable' if options[:no_format_executable]
args << '--previous-version' << Gem::VERSION if
options[:system] == true or
diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb
index 39b00387ea..fb3053fd83 100644
--- a/lib/rubygems/core_ext/kernel_gem.rb
+++ b/lib/rubygems/core_ext/kernel_gem.rb
@@ -7,9 +7,6 @@
module Kernel
- # REFACTOR: This should be pulled out into some kind of hacks file.
- remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
-
##
# Use Kernel#gem to activate a specific version of +gem_name+.
#
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 7aa0480b80..33b6ab3f3e 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -148,13 +148,6 @@ module Gem
end
##
- # Whether to expect full paths in default gems - true for non-MRI
- # ruby implementations
- def self.default_gems_use_full_paths?
- ruby_engine != 'ruby'
- end
-
- ##
# Install extensions into lib as well as into the extension directory.
def self.install_extension_in_lib # :nodoc:
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 52041a2713..077f080c07 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -20,7 +20,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
rake = rake.shellsplit
else
begin
- rake = [Gem.ruby, "-rrubygems", Gem.bin_path('rake', 'rake')]
+ rake = [Gem.ruby, "-I#{File.expand_path("..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')]
rescue Gem::Exception
rake = [Gem.default_exec_format % 'rake']
end
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index 1c16959f5f..f48466d3ea 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -66,44 +66,9 @@ end
class Gem::InstallerTestCase < Gem::TestCase
- ##
- # Creates the following instance variables:
- #
- # @spec::
- # a spec named 'a', intended for regular installs
- # @user_spec::
- # a spec named 'b', intended for user installs
- #
- # @gem::
- # the path to a built gem from @spec
- # @user_spec::
- # the path to a built gem from @user_spec
- #
- # @installer::
- # a Gem::Installer for the @spec that installs into @gemhome
- # @user_installer::
- # a Gem::Installer for the @user_spec that installs into Gem.user_dir
-
def setup
super
- @spec = quick_gem 'a' do |spec|
- util_make_exec spec
- end
-
- @user_spec = quick_gem 'b' do |spec|
- util_make_exec spec
- end
-
- util_build_gem @spec
- util_build_gem @user_spec
-
- @gem = @spec.cache_file
- @user_gem = @user_spec.cache_file
-
- @installer = util_installer @spec, @gemhome
- @user_installer = util_installer @user_spec, Gem.user_dir, :user
-
Gem::Installer.path_warning = false
end
@@ -136,6 +101,83 @@ class Gem::InstallerTestCase < Gem::TestCase
end
##
+ # Creates the following instance variables:
+ #
+ # @spec::
+ # a spec named 'a', intended for regular installs
+ #
+ # @gem::
+ # the path to a built gem from @spec
+ #
+ # And returns a Gem::Installer for the @spec that installs into @gemhome
+
+ def setup_base_installer
+ @gem = setup_base_gem
+ util_installer @spec, @gemhome
+ end
+
+ ##
+ # Creates the following instance variables:
+ #
+ # @spec::
+ # a spec named 'a', intended for regular installs
+ #
+ # And returns a gem built for the @spec
+
+ def setup_base_gem
+ @spec = setup_base_spec
+ util_build_gem @spec
+ @spec.cache_file
+ end
+
+ ##
+ # Sets up a generic specification for testing the rubygems installer
+ #
+ # And returns it
+
+ def setup_base_spec
+ quick_gem 'a' do |spec|
+ util_make_exec spec
+ end
+ end
+
+ ##
+ # Creates the following instance variables:
+ #
+ # @spec::
+ # a spec named 'a', intended for regular installs
+ # @user_spec::
+ # a spec named 'b', intended for user installs
+ #
+ # @gem::
+ # the path to a built gem from @spec
+ # @user_gem::
+ # the path to a built gem from @user_spec
+ #
+ # And returns a Gem::Installer for the @user_spec that installs into Gem.user_dir
+
+ def setup_base_user_installer
+ @user_spec = quick_gem 'b' do |spec|
+ util_make_exec spec
+ end
+
+ util_build_gem @user_spec
+
+ @user_gem = @user_spec.cache_file
+
+ util_installer @user_spec, Gem.user_dir, :user
+ end
+
+ ##
+ # Sets up the base @gem, builds it and returns an installer for it.
+ #
+ def util_setup_installer
+ @gem = setup_base_gem
+
+ util_setup_gem
+ end
+
+ ##
# Builds the @spec gem and returns an installer for it. The built gem
# includes:
#
@@ -143,7 +185,7 @@ class Gem::InstallerTestCase < Gem::TestCase
# lib/code.rb
# ext/a/mkrf_conf.rb
- def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic
+ def util_setup_gem(ui = @ui)
@spec.files << File.join('lib', 'code.rb')
@spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
@@ -175,7 +217,7 @@ class Gem::InstallerTestCase < Gem::TestCase
end
end
- @installer = Gem::Installer.at @gem
+ Gem::Installer.at @gem
end
##
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index c7b5f88dbd..c37612772a 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -107,8 +107,8 @@ class Gem::Package::TarHeader
new :name => fields.shift,
:mode => strict_oct(fields.shift),
- :uid => strict_oct(fields.shift),
- :gid => strict_oct(fields.shift),
+ :uid => oct_or_256based(fields.shift),
+ :gid => oct_or_256based(fields.shift),
:size => strict_oct(fields.shift),
:mtime => strict_oct(fields.shift),
:checksum => strict_oct(fields.shift),
@@ -130,6 +130,15 @@ class Gem::Package::TarHeader
raise ArgumentError, "#{str.inspect} is not an octal string"
end
+ def self.oct_or_256based(str)
+ # \x80 flags a positive 256-based number
+ # \ff flags a negative 256-based number
+ # In case we have a match, parse it as a signed binary value
+ # in big-endian order, except that the high-order bit is ignored.
+ return str.unpack('N2').last if str =~ /\A[\x80\xff]/n
+ strict_oct(str)
+ end
+
##
# Creates a new TarHeader using +vals+
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 32c65eada8..a40ee55273 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -173,7 +173,7 @@ class Gem::RemoteFetcher
path = source_uri.path
path = File.dirname(path) if File.extname(path) == '.gem'
- remote_gem_path = correct_for_windows_path(File.join(path, 'gems', gem_file_name))
+ remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, 'gems', gem_file_name))
FileUtils.cp(remote_gem_path, local_gem_path)
rescue Errno::EACCES
@@ -210,7 +210,7 @@ class Gem::RemoteFetcher
# File Fetcher. Dispatched by +fetch_path+. Use it instead.
def fetch_file(uri, *_)
- Gem.read_binary correct_for_windows_path uri.path
+ Gem.read_binary Gem::Util.correct_for_windows_path uri.path
end
##
@@ -317,14 +317,6 @@ class Gem::RemoteFetcher
response['content-length'].to_i
end
- def correct_for_windows_path(path)
- if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
- path[1..-1]
- else
- path
- end
- end
-
##
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
# a Net::HTTP response object. request maintains a table of persistent
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index 7c273d5465..9444239b2c 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -76,9 +76,7 @@ class Gem::Request::ConnectionPools # :nodoc:
end
def net_http_args(uri, proxy_uri)
- # URI::Generic#hostname was added in ruby 1.9.3, use it if exists, otherwise
- # don't support IPv6 literals and use host.
- hostname = uri.respond_to?(:hostname) ? uri.hostname : uri.host
+ hostname = uri.hostname
net_http_args = [hostname, uri.port]
no_proxy = get_no_proxy_from_env
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index d308f68f21..f74995713b 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -246,7 +246,7 @@ class Gem::Resolver
sources.each do |source|
groups[source].
sort_by { |spec| [spec.version, Gem::Platform.local =~ spec.platform ? 1 : 0] }.
- map { |spec| ActivationRequest.new spec, dependency, [] }.
+ map { |spec| ActivationRequest.new spec, dependency }.
each { |activation_request| activation_requests << activation_request }
end
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index 7fbabbff50..2a8d6032f8 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -18,14 +18,10 @@ class Gem::Resolver::ActivationRequest
##
# Creates a new ActivationRequest that will activate +spec+. The parent
# +request+ is used to provide diagnostics in case of conflicts.
- #
- # +others_possible+ indicates that other specifications may also match this
- # activation request.
- def initialize(spec, request, others_possible = true)
+ def initialize(spec, request)
@spec = spec
@request = request
- @others_possible = others_possible
end
def ==(other) # :nodoc:
@@ -90,21 +86,8 @@ class Gem::Resolver::ActivationRequest
end
def inspect # :nodoc:
- others =
- case @others_possible
- when true then # TODO remove at RubyGems 3
- ' (others possible)'
- when false then # TODO remove at RubyGems 3
- nil
- else
- unless @others_possible.empty?
- others = @others_possible.map { |s| s.full_name }
- " (others possible: #{others.join ', '})"
- end
- end
-
- '#<%s for %p from %s%s>' % [
- self.class, @spec, @request, others
+ '#<%s for %p from %s>' % [
+ self.class, @spec, @request
]
end
@@ -132,19 +115,6 @@ class Gem::Resolver::ActivationRequest
end
##
- # Indicate if this activation is one of a set of possible
- # requests for the same Dependency request.
-
- def others_possible?
- case @others_possible
- when true, false then
- @others_possible
- else
- not @others_possible.empty?
- end
- end
-
- ##
# Return the ActivationRequest that contained the dependency
# that we were activated for.
@@ -160,19 +130,6 @@ class Gem::Resolver::ActivationRequest
q.breakable
q.text ' for '
q.pp @request
-
- case @others_possible
- when false then
- when true then
- q.breakable
- q.text 'others possible'
- else
- unless @others_possible.empty?
- q.breakable
- q.text 'others '
- q.pp @others_possible.map { |s| s.full_name }
- end
- end
end
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 942e49bf84..c1286369be 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -743,9 +743,6 @@ class Gem::Specification < Gem::BasicSpecification
def self._all # :nodoc:
unless defined?(@@all) && @@all
@@all = stubs.map(&:to_spec)
- if @@all.any?(&:nil?) # TODO: remove once we're happy
- raise "pid: #{$$} nil spec! included in #{stubs.inspect}"
- end
# After a reset, make sure already loaded specs
# are still marked as activated.
@@ -896,7 +893,6 @@ class Gem::Specification < Gem::BasicSpecification
# -- wilsonb
def self.all=(specs)
- raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
@@stubs_by_name = specs.group_by(&:name)
@@all = @@stubs = specs
end
@@ -1498,16 +1494,7 @@ class Gem::Specification < Gem::BasicSpecification
paths = full_require_paths
- # gem directories must come after -I and ENV['RUBYLIB']
- insert_index = Gem.load_path_insert_index
-
- if insert_index
- # gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *paths)
- else
- # we are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*paths)
- end
+ Gem.add_to_load_path(*paths)
end
##
@@ -1927,8 +1914,7 @@ class Gem::Specification < Gem::BasicSpecification
end
def gems_dir
- # TODO: this logic seems terribly broken, but tests fail if just base_dir
- @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
+ @gems_dir ||= File.join(base_dir, "gems")
end
##
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 8e909e4afe..b466e7a4e0 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-# TODO: $SAFE = 1
require 'rubygems'
@@ -27,13 +26,6 @@ begin
rescue LoadError
end
-# We have to load these up front because otherwise we'll try to load
-# them while we're testing rubygems, and thus we can't actually load them.
-unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
- gem 'rdoc'
- gem 'json'
-end
-
require 'bundler'
require 'minitest/autorun'
@@ -91,8 +83,6 @@ end
# gem-related behavior in a sandbox. Through RubyGemTestCase you can install
# and uninstall gems, fetch remote gems through a stub fetcher and be assured
# your normal set of gems is not affected.
-#
-# Tests are always run at a safe level of 1.
class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase)
@@ -152,6 +142,28 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
end
+ ##
+ # Sets the vendordir entry in RbConfig::CONFIG to +value+ and restores the
+ # original value when the block ends
+ #
+ def vendordir(value)
+ vendordir = RbConfig::CONFIG['vendordir']
+
+ if value
+ RbConfig::CONFIG['vendordir'] = value
+ else
+ RbConfig::CONFIG.delete 'vendordir'
+ end
+
+ yield
+ ensure
+ if vendordir
+ RbConfig::CONFIG['vendordir'] = vendordir
+ else
+ RbConfig::CONFIG.delete 'vendordir'
+ end
+ end
+
# TODO: move to minitest
def refute_path_exists(path, msg = nil)
msg = message(msg) { "Expected path '#{path}' to not exist" }
@@ -222,8 +234,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
@@project_dir = Dir.pwd.untaint unless defined?(@@project_dir)
- @@initial_reset = false
-
##
# #setup prepares a sandboxed location to install gems. All installs are
# directed to a temporary directory. All install plugins are removed.
@@ -231,24 +241,11 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# If the +RUBY+ environment variable is set the given path is used for
# Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
# or <tt>i686-darwin8.10.1</tt> otherwise.
- #
- # If the +KEEP_FILES+ environment variable is set the files will not be
- # removed from <tt>/tmp/test_rubygems_#{$$}.#{Time.now.to_i}</tt>.
def setup
super
- @orig_gem_home = ENV['GEM_HOME']
- @orig_gem_path = ENV['GEM_PATH']
- @orig_gem_vendor = ENV['GEM_VENDOR']
- @orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
- @orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
- @orig_bundle_gemfile = ENV['BUNDLE_GEMFILE']
- @orig_rubygems_host = ENV['RUBYGEMS_HOST']
- ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
- ENV.delete k
- end
- @orig_gem_env_requirements = ENV.to_hash
+ @orig_env = ENV.to_hash
ENV['GEM_VENDOR'] = nil
ENV['SOURCE_DATE_EPOCH'] = nil
@@ -256,36 +253,20 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
@current_dir = Dir.pwd
@fetcher = nil
- Bundler.ui = Bundler::UI::Silent.new
-
@back_ui = Gem::DefaultUserInteraction.ui
@ui = Gem::MockGemUi.new
# This needs to be a new instance since we call use_ui(@ui) when we want to
# capture output
Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
- tmpdir = File.expand_path Dir.tmpdir
+ tmpdir = File.realpath Dir.tmpdir
tmpdir.untaint
- if ENV['KEEP_FILES']
- @tempdir = File.join(tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}")
- else
- @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
- end
+ @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
@tempdir.untaint
FileUtils.mkdir_p @tempdir
- # This makes the tempdir consistent on OS X.
- # File.expand_path Dir.tmpdir #=> "/var/..."
- # Dir.chdir Dir.tmpdir do File.expand_path '.' end #=> "/private/var/..."
- # TODO use File#realpath above instead of #expand_path once 1.8 support is
- # dropped.
- Dir.chdir @tempdir do
- @tempdir = File.expand_path '.'
- @tempdir.untaint
- end
-
# This makes the tempdir consistent on Windows.
# Dir.tmpdir may return short path name, but Dir[Dir.tmpdir] returns long
# path name. https://bugs.ruby-lang.org/issues/10819
@@ -343,25 +324,21 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
@default_dir = File.join @tempdir, 'default'
@default_spec_dir = File.join @default_dir, "specifications", "default"
- Gem.instance_variable_set :@default_dir, @default_dir
- FileUtils.mkdir_p @default_spec_dir
-
- # We use Gem::Specification.reset the first time only so that if there
- # are unresolved deps that leak into the whole test suite, they're at least
- # reported once.
- if @@initial_reset
- Gem::Specification.unresolved_deps.clear # done to avoid cross-test warnings
+ if Gem.java_platform?
+ @orig_default_gem_home = RbConfig::CONFIG['default_gem_home']
+ RbConfig::CONFIG['default_gem_home'] = @default_dir
else
- @@initial_reset = true
- Gem::Specification.reset
+ Gem.instance_variable_set(:@default_dir, @default_dir)
end
+ FileUtils.mkdir_p @default_spec_dir
+
+ Gem::Specification.unresolved_deps.clear
Gem.use_paths(@gemhome)
Gem::Security.reset
Gem.loaded_specs.clear
Gem.clear_default_specs
- Gem::Specification.unresolved_deps.clear
Bundler.reset!
Gem.configuration.verbose = true
@@ -395,7 +372,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
##
# #teardown restores the process to its original state and removes the
- # tempdir unless the +KEEP_FILES+ environment variable was set.
+ # tempdir
def teardown
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
@@ -420,33 +397,18 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Dir.chdir @current_dir
- FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
+ FileUtils.rm_rf @tempdir
- ENV.clear
- @orig_gem_env_requirements.each do |k,v|
- ENV[k] = v
- end
-
- ENV['GEM_HOME'] = @orig_gem_home
- ENV['GEM_PATH'] = @orig_gem_path
- ENV['GEM_VENDOR'] = @orig_gem_vendor
- ENV['GEM_SPEC_CACHE'] = @orig_gem_spec_cache
- ENV['RUBYGEMS_GEMDEPS'] = @orig_rubygems_gemdeps
- ENV['BUNDLE_GEMFILE'] = @orig_bundle_gemfile
- ENV['RUBYGEMS_HOST'] = @orig_rubygems_host
+ ENV.replace(@orig_env)
Gem.ruby = @orig_ruby if @orig_ruby
- if @orig_ENV_HOME
- ENV['HOME'] = @orig_ENV_HOME
+ if Gem.java_platform?
+ RbConfig::CONFIG['default_gem_home'] = @orig_default_gem_home
else
- ENV.delete 'HOME'
+ Gem.instance_variable_set :@default_dir, nil
end
- Gem.instance_variable_set :@default_dir, nil
-
- ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = @orig_gem_private_key_passphrase
-
Gem::Specification._clear_load_cache
Gem::Specification.unresolved_deps.clear
Gem::refresh
@@ -594,22 +556,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
##
- # creates a temporary directory with hax
- # TODO: deprecate and remove
-
- def create_tmpdir
- tmpdir = nil
-
- Dir.chdir Dir.tmpdir do
- tmpdir = Dir.pwd
- end # HACK OSX /private/tmp
-
- tmpdir = File.join tmpdir, "test_rubygems_#{$$}"
- FileUtils.mkdir_p tmpdir
- return tmpdir
- end
-
- ##
# Enables pretty-print for all tests
def mu_pp(obj)
@@ -686,7 +632,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
io.write spec.to_ruby_for_cache
end
- spec.loaded_from = spec.loaded_from = written_path
+ spec.loaded_from = written_path
Gem::Specification.reset
@@ -694,14 +640,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
##
- # TODO: remove in RubyGems 4.0
-
- def quick_spec(name, version = '2') # :nodoc:
- util_spec name, version
- end
- deprecate :quick_spec, :util_spec, 2018, 12
-
- ##
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
# 'cache'</tt>. Automatically creates files based on +spec.files+
@@ -744,11 +682,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem::Specification.reset
end
- def util_clear_default_gems
- FileUtils.rm_rf @default_spec_dir
- FileUtils.mkdir @default_spec_dir
- end
-
##
# Install the provided specs
@@ -802,52 +735,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
$LOADED_FEATURES.replace old_loaded_features
end
- ##
- # new_spec is deprecated as it is never used.
- #
- # TODO: remove in RubyGems 4.0
-
- def new_spec(name, version, deps = nil, *files) # :nodoc:
- require 'rubygems/specification'
-
- spec = Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = name
- s.version = version
- s.author = 'A User'
- s.email = 'example@example.com'
- s.homepage = 'http://example.com'
- s.summary = "this is a summary"
- s.description = "This is a test description"
-
- Array(deps).each do |n, req|
- s.add_dependency n, (req || '>= 0')
- end
-
- s.files.push(*files) unless files.empty?
-
- yield s if block_given?
- end
-
- spec.loaded_from = spec.spec_file
-
- unless files.empty?
- write_file spec.spec_file do |io|
- io.write spec.to_ruby_for_cache
- end
-
- util_build_gem spec
-
- cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
- FileUtils.mkdir_p File.dirname cache_file
- FileUtils.mv spec.cache_file, cache_file
- FileUtils.rm spec.spec_file
- end
-
- spec
- end
- deprecate :new_spec, :none, 2018, 12
-
def new_default_spec(name, version, deps = nil, *files)
spec = util_spec name, version, deps
@@ -910,8 +797,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
FileUtils.rm spec.spec_file
end
- Gem::Specification.reset
-
return spec
end
@@ -1061,31 +946,6 @@ Also, a list:
end
##
- # Sets up a fake fetcher using the gems from #util_make_gems. Optionally
- # additional +prerelease+ gems may be included.
- #
- # Gems created by this method may be fetched using Gem::RemoteFetcher.
-
- def util_setup_fake_fetcher(prerelease = false)
- require 'zlib'
- require 'socket'
- require 'rubygems/remote_fetcher'
-
- @fetcher = Gem::FakeFetcher.new
-
- util_make_gems(prerelease)
- Gem::Specification.reset
-
- @all_gems = [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2].sort
- @all_gem_names = @all_gems.map { |gem| gem.full_name }
-
- gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
- @gem_names = gem_names.sort.join("\n")
-
- Gem::RemoteFetcher.fetcher = @fetcher
- end
-
- ##
# Add +spec+ to +@fetcher+ serving the data in the file +path+.
# +repo+ indicates which repo to make +spec+ appear to be in.
@@ -1096,7 +956,6 @@ Also, a list:
##
# Sets up Gem::SpecFetcher to return information from the gems in +specs+.
- # Best used with +@all_gems+ from #util_setup_fake_fetcher.
def util_setup_spec_fetcher(*specs)
all_specs = Gem::Specification.to_a + specs
@@ -1163,8 +1022,7 @@ Also, a list:
end
def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil, description = nil, engine = "ruby", engine_version = nil)
- if Gem.instance_variables.include? :@ruby_version or
- Gem.instance_variables.include? '@ruby_version'
+ if Gem.instance_variables.include? :@ruby_version
Gem.send :remove_instance_variable, :@ruby_version
end
@@ -1224,6 +1082,20 @@ Also, a list:
end
##
+ # Is this test being run on a Java platform?
+
+ def self.java_platform?
+ Gem.java_platform?
+ end
+
+ ##
+ # Is this test being run on a Java platform?
+
+ def java_platform?
+ Gem.java_platform?
+ end
+
+ ##
# Returns whether or not we're on a version of Ruby built with VC++ (or
# Borland) versus Cygwin, Mingw, etc.
@@ -1623,10 +1495,3 @@ rescue LoadError, Gem::LoadError
end
require 'rubygems/test_utilities'
-tmpdirs = []
-tmpdirs << (ENV['GEM_HOME'] = Dir.mktmpdir("home"))
-tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
-pid = $$
-END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
-Gem.clear_paths
-Gem.loaded_specs.clear
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 5d02b04897..69ff05370e 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -241,21 +241,22 @@ class Gem::TestCase::SpecFetcherSetup
def execute_operations # :nodoc:
@operations.each do |operation, *arguments|
+ block = arguments.pop
case operation
when :gem then
- spec, gem = @test.util_gem(*arguments, &arguments.pop)
+ spec, gem = @test.util_gem(*arguments, &block)
write_spec spec
@gems[spec] = gem
@installed << spec
when :download then
- spec, gem = @test.util_gem(*arguments, &arguments.pop)
+ spec, gem = @test.util_gem(*arguments, &block)
@gems[spec] = gem
@downloaded << spec
when :spec then
- spec = @test.util_spec(*arguments, &arguments.pop)
+ spec = @test.util_spec(*arguments, &block)
write_spec spec
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index 401e5609f7..b5f1408401 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -44,29 +44,10 @@ module Gem::Util
end
##
- # This calls IO.popen where it accepts an array for a +command+ (Ruby 1.9+)
- # and implements an IO.popen-like behavior where it does not accept an array
- # for a command.
+ # This calls IO.popen and reads the result
def self.popen(*command)
IO.popen command, &:read
- rescue TypeError # ruby 1.8 only supports string command
- r, w = IO.pipe
-
- pid = fork do
- STDIN.close
- STDOUT.reopen w
-
- exec(*command)
- end
-
- w.close
-
- begin
- return r.read
- ensure
- Process.wait pid
- end
end
##
@@ -80,26 +61,7 @@ module Gem::Util
else
cmds = command.dup
end
- return system(*(cmds << opt))
- rescue TypeError
- @silent_mutex ||= Mutex.new
-
- @silent_mutex.synchronize do
- begin
- stdout = STDOUT.dup
- stderr = STDERR.dup
-
- STDOUT.reopen IO::NULL, 'w'
- STDERR.reopen IO::NULL, 'w'
-
- return system(*command)
- ensure
- STDOUT.reopen stdout
- STDERR.reopen stderr
- stdout.close
- stderr.close
- end
- end
+ system(*(cmds << opt))
end
##
@@ -130,4 +92,16 @@ module Gem::Util
end
end
+ ##
+ # Corrects +path+ (usually returned by `URI.parse().path` on Windows), that
+ # comes with a leading slash.
+
+ def self.correct_for_windows_path(path)
+ if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
+ path[1..-1]
+ else
+ path
+ end
+ end
+
end
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|