summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-10-17 16:12:09 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2024-10-17 08:55:01 -0700
commit494fcc507b3bc218beb6638d33476b647d55969e (patch)
treed685c173f72dd5cc3be063d0fe2fa5ee958d99f0 /test
parentd03e4228aaeb1bdd3432119e683aa259b028c5b2 (diff)
Merge RubyGems-3.5.22 and Bundler-2.5.22
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem.rb14
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_exec_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb16
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb42
-rw-r--r--test/rubygems/test_gem_installer.rb6
-rw-r--r--test/rubygems/test_gem_specification.rb12
-rw-r--r--test/rubygems/test_gem_stub_specification.rb95
-rw-r--r--test/rubygems/test_require.rb2
9 files changed, 139 insertions, 56 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 0d048b08b7..cdc3479e37 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1026,6 +1026,20 @@ class TestGem < Gem::TestCase
Gem.refresh
end
+ def test_activated_specs_does_not_cause_duplicates_when_looping_through_specs
+ util_make_gems
+
+ s = Gem::Specification.first
+ s.activate
+
+ Gem.refresh
+
+ assert_equal 1, Gem::Specification.count {|spec| spec.full_name == s.full_name }
+
+ Gem.loaded_specs.delete(s)
+ Gem.refresh
+ end
+
def test_self_ruby_escaping_spaces_in_path
with_clean_path_to_ruby do
with_rb_config_ruby("C:/Ruby 1.8/bin/ruby.exe") do
diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
index d8e6ba3dec..049afe8a01 100644
--- a/test/rubygems/test_gem_commands_contents_command.rb
+++ b/test/rubygems/test_gem_commands_contents_command.rb
@@ -227,7 +227,6 @@ lib/foo.rb
default_gem_spec = new_default_spec("default", "2.0.0.0",
nil, "default/gem.rb")
default_gem_spec.executables = ["default_command"]
- default_gem_spec.files += ["default_gem.so"]
install_default_gems(default_gem_spec)
@cmd.options[:args] = %w[default]
@@ -237,9 +236,8 @@ lib/foo.rb
end
expected = [
- [RbConfig::CONFIG["bindir"], "default_command"],
- [RbConfig::CONFIG["rubylibdir"], "default/gem.rb"],
- [RbConfig::CONFIG["archdir"], "default_gem.so"],
+ [File.join(@gemhome, "bin"), "default_command"],
+ [File.join(@tempdir, "default_gems", "lib"), "default/gem.rb"],
].sort.map {|a|File.join a }.join "\n"
assert_equal expected, @ui.output.chomp
diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb
index c632ce62b2..b9d5888068 100644
--- a/test/rubygems/test_gem_commands_exec_command.rb
+++ b/test/rubygems/test_gem_commands_exec_command.rb
@@ -215,7 +215,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
end
def test_gem_with_platform_and_platform_dependencies
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
pend "terminates on mswin" if vc_windows? && ruby_repo?
spec_fetcher do |fetcher|
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index b8b39133ff..46c06db014 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -630,8 +630,16 @@ class TestGemCommandsPristineCommand < Gem::TestCase
def test_execute_default_gem
default_gem_spec = new_default_spec("default", "2.0.0.0",
- nil, "default/gem.rb")
- install_default_gems(default_gem_spec)
+ nil, "exe/executable")
+ default_gem_spec.executables = "executable"
+ install_default_gems default_gem_spec
+
+ exe = File.join @gemhome, "bin", "executable"
+
+ assert_path_exist exe, "default gem's executable not installed"
+
+ content_with_replaced_shebang = File.read(exe).gsub(/^#![^\n]+ruby/, "#!/usr/bin/env ruby_executable_hooks")
+ File.write(exe, content_with_replaced_shebang)
@cmd.options[:args] = %w[default]
@@ -642,11 +650,13 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_equal(
[
"Restoring gems to pristine condition...",
- "Skipped default-2.0.0.0, it is a default gem",
+ "Restored default-2.0.0.0",
],
@ui.output.split("\n")
)
assert_empty(@ui.error)
+
+ refute_includes "ruby_executable_hooks", File.read(exe)
end
def test_execute_multi_platform
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 8999723ba1..56b84160c4 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -819,6 +819,48 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1], inst.installed_gems.map(&:full_name)
end
+ def test_install_dual_repository_and_done_installing_hooks
+ util_setup_gems
+
+ FileUtils.mv @a1_gem, @tempdir
+ FileUtils.mv @b1_gem, @tempdir
+ inst = nil
+
+ # Make sure gem is installed to standard GEM_HOME
+
+ Dir.chdir @tempdir do
+ inst = Gem::DependencyInstaller.new install_dir: @gemhome
+ inst.install "b"
+ end
+
+ # and also to an additional GEM_PATH
+
+ gemhome2 = "#{@gemhome}2"
+
+ Dir.chdir @tempdir do
+ inst = Gem::DependencyInstaller.new install_dir: gemhome2
+ inst.install "b"
+ end
+
+ # Now install the local gem with the additional GEM_PATH
+
+ ENV["GEM_HOME"] = @gemhome
+ ENV["GEM_PATH"] = [@gemhome, gemhome2].join File::PATH_SEPARATOR
+ Gem.clear_paths
+
+ Gem.done_installing do |installer, specs|
+ refute_nil installer
+ assert_equal [@b1], specs
+ end
+
+ Dir.chdir @tempdir do
+ inst = Gem::DependencyInstaller.new
+ inst.install "b-1.gem"
+ end
+
+ assert_equal %w[b-1], inst.installed_gems.map(&:full_name)
+ end
+
def test_install_remote
util_setup_gems
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 326aee147c..b7b2342c6a 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -1567,7 +1567,7 @@ end
end
def test_find_lib_file_after_install
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
@@ -1655,7 +1655,7 @@ end
end
def test_install_extension_flat
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
begin
@spec = setup_base_spec
@@ -1706,7 +1706,7 @@ end
end
def test_install_extension_clean_intermediate_files
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
@spec = setup_base_spec
@spec.require_paths = ["."]
@spec.extensions << "extconf.rb"
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index fbe52aa317..b2ca2b368e 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1334,7 +1334,6 @@ dependencies: []
end
def test_build_args
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert_empty @ext.build_args
@@ -1351,7 +1350,6 @@ dependencies: []
end
def test_build_extensions
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert_path_not_exist @ext.extension_dir, "sanity check"
@@ -1387,7 +1385,6 @@ dependencies: []
end
def test_build_extensions_built
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, "sanity check"
@@ -1426,7 +1423,6 @@ dependencies: []
end
def test_build_extensions_error
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, "sanity check"
@@ -1440,7 +1436,7 @@ dependencies: []
pend "chmod not supported" if Gem.win_platform?
pend "skipped in root privilege" if Process.uid.zero?
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, "sanity check"
@@ -1473,7 +1469,6 @@ dependencies: []
def test_build_extensions_no_extensions_dir_unwritable
pend "chmod not supported" if Gem.win_platform?
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, "sanity check"
@@ -1512,7 +1507,6 @@ dependencies: []
end
def test_build_extensions_preview
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
@@ -1547,7 +1541,6 @@ dependencies: []
end
def test_contains_requirable_file_eh_extension
- pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
_, err = capture_output do
@@ -2368,7 +2361,7 @@ Gem::Specification.new do |s|
s.rubygems_version = "#{Gem::VERSION}".freeze
s.summary = "this is a summary".freeze
- s.installed_by_version = "#{Gem::VERSION}".freeze if s.respond_to? :installed_by_version
+ s.installed_by_version = "#{Gem::VERSION}".freeze
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
@@ -3823,7 +3816,6 @@ end
end
def test_missing_extensions_eh
- pend "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 fe30a78c0b..4b2d4c570a 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -66,7 +66,6 @@ class TestStubSpecification < Gem::TestCase
end
def test_contains_requirable_file_eh_extension
- pend "I guess making the stub match the running platform should work" if Gem.java_platform?
stub_with_extension do |stub|
_, err = capture_output do
refute stub.contains_requirable_file? "nonexistent"
@@ -123,7 +122,6 @@ class TestStubSpecification < Gem::TestCase
end
def test_missing_extensions_eh
- pend "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
@@ -173,6 +171,35 @@ class TestStubSpecification < Gem::TestCase
assert_same real_foo, @foo.to_spec
end
+ def test_to_spec_default
+ bar_default_spec = File.join(@gemhome, "specifications", "default", "bar-0.0.2.gemspec")
+ File.open bar_default_spec, "w" do |io|
+ io.write <<~STUB
+ # -*- encoding: utf-8 -*-
+ # stub: bar 0.0.2 ruby lib
+
+ Gem::Specification.new do |s|
+ s.name = "bar"
+ s.version = "0.0.2"
+ s.platform = "ruby"
+ s.require_paths = ["lib"]
+ s.summary = "A very bar gem"
+ end
+ STUB
+ end
+
+ bar = Gem::StubSpecification.gemspec_stub BAR, @base_dir, @gems_dir
+ bar_default = Gem::StubSpecification.default_gemspec_stub bar_default_spec, @base_dir, @gems_dir
+
+ real_bar = util_spec bar_default.name, bar_default.version
+ real_bar.activate
+
+ assert_equal bar.version, Gem.loaded_specs[bar.name].version,
+ "sanity check"
+
+ refute_same real_bar, bar_default.to_spec
+ end
+
def test_to_spec_with_other_specs_loaded_does_not_warn
real_foo = util_spec @foo.name, @foo.version
real_foo.activate
@@ -184,14 +211,14 @@ class TestStubSpecification < Gem::TestCase
def stub_with_version
spec = File.join @gemhome, "specifications", "stub_e-2.gemspec"
File.open spec, "w" do |io|
- io.write <<-STUB
-# -*- encoding: utf-8 -*-
-# stub: stub_v 2 ruby lib
+ io.write <<~STUB
+ # -*- encoding: utf-8 -*-
+ # stub: stub_v 2 ruby lib
-Gem::Specification.new do |s|
- s.name = 'stub_v'
- s.version = Gem::Version.new '2'
-end
+ Gem::Specification.new do |s|
+ s.name = 'stub_v'
+ s.version = Gem::Version.new '2'
+ end
STUB
io.flush
@@ -207,14 +234,14 @@ end
def stub_without_version
spec = File.join @gemhome, "specifications", "stub-2.gemspec"
File.open spec, "w" do |io|
- io.write <<-STUB
-# -*- encoding: utf-8 -*-
-# stub: stub_v ruby lib
+ io.write <<~STUB
+ # -*- encoding: utf-8 -*-
+ # stub: stub_v ruby lib
-Gem::Specification.new do |s|
- s.name = 'stub_v'
- s.version = ""
-end
+ Gem::Specification.new do |s|
+ s.name = 'stub_v'
+ s.version = ""
+ end
STUB
io.flush
@@ -230,17 +257,17 @@ end
def stub_with_extension
spec = File.join @gemhome, "specifications", "stub_e-2.gemspec"
File.open spec, "w" do |io|
- io.write <<-STUB
-# -*- encoding: utf-8 -*-
-# stub: stub_e 2 ruby lib
-# stub: ext/stub_e/extconf.rb
-
-Gem::Specification.new do |s|
- s.name = 'stub_e'
- s.version = Gem::Version.new '2'
- s.extensions = ['ext/stub_e/extconf.rb']
- s.installed_by_version = '2.2'
-end
+ io.write <<~STUB
+ # -*- encoding: utf-8 -*-
+ # stub: stub_e 2 ruby lib
+ # stub: ext/stub_e/extconf.rb
+
+ Gem::Specification.new do |s|
+ s.name = 'stub_e'
+ s.version = Gem::Version.new '2'
+ s.extensions = ['ext/stub_e/extconf.rb']
+ s.installed_by_version = '2.2'
+ end
STUB
io.flush
@@ -256,14 +283,14 @@ end
def stub_without_extension
spec = File.join @gemhome, "specifications", "stub-2.gemspec"
File.open spec, "w" do |io|
- io.write <<-STUB
-# -*- encoding: utf-8 -*-
-# stub: stub 2 ruby lib
+ io.write <<~STUB
+ # -*- encoding: utf-8 -*-
+ # stub: stub 2 ruby lib
-Gem::Specification.new do |s|
- s.name = 'stub'
- s.version = Gem::Version.new '2'
-end
+ Gem::Specification.new do |s|
+ s.name = 'stub'
+ s.version = Gem::Version.new '2'
+ end
STUB
io.flush
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index f15e9b6243..f63c23c315 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -130,7 +130,7 @@ class TestGemRequire < Gem::TestCase
end
def test_dash_i_respects_default_library_extension_priority
- pend "extensions don't quite work on jruby" if Gem.java_platform?
+ pend "needs investigation" if Gem.java_platform?
pend "not installed yet" unless RbConfig::TOPDIR
dash_i_ext_arg = util_install_extension_file("a")