[rubygems/rubygems] Use preferred add_dependency instead of add_runtime_dependency

https://github.com/rubygems/rubygems/commit/9a08043858
This commit is contained in:
Jerome Dalbert 2024-07-04 12:49:33 -07:00 committed by git
parent c480dec1cc
commit bbb4da78c7
13 changed files with 46 additions and 46 deletions

View File

@ -1188,19 +1188,19 @@ RSpec.describe "bundle install with gem sources" do
build_gem "nokogiri", "1.12.4" do |s| build_gem "nokogiri", "1.12.4" do |s|
s.platform = "x86_64-darwin" s.platform = "x86_64-darwin"
s.add_runtime_dependency "racca", "~> 1.4" s.add_dependency "racca", "~> 1.4"
end end
build_gem "nokogiri", "1.12.4" do |s| build_gem "nokogiri", "1.12.4" do |s|
s.platform = "x86_64-linux" s.platform = "x86_64-linux"
s.add_runtime_dependency "racca", "~> 1.4" s.add_dependency "racca", "~> 1.4"
end end
build_gem "crass", "1.0.6" build_gem "crass", "1.0.6"
build_gem "loofah", "2.12.0" do |s| build_gem "loofah", "2.12.0" do |s|
s.add_runtime_dependency "crass", "~> 1.0.2" s.add_dependency "crass", "~> 1.0.2"
s.add_runtime_dependency "nokogiri", ">= 1.5.9" s.add_dependency "nokogiri", ">= 1.5.9"
end end
end end

View File

@ -54,7 +54,7 @@ RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do
context "when also a transitive dependency" do context "when also a transitive dependency" do
before do before do
build_repo4 do build_repo4 do
build_gem("depends_on_platform_specific") {|s| s.add_runtime_dependency "platform_specific" } build_gem("depends_on_platform_specific") {|s| s.add_dependency "platform_specific" }
build_gem("platform_specific") do |s| build_gem("platform_specific") do |s|
s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'" s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
@ -83,12 +83,12 @@ RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do
before do before do
build_repo4 do build_repo4 do
build_gem("depends_on_platform_specific") do |s| build_gem("depends_on_platform_specific") do |s|
s.add_runtime_dependency "platform_specific" s.add_dependency "platform_specific"
s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 RUBY'" s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 RUBY'"
end end
build_gem("depends_on_platform_specific") do |s| build_gem("depends_on_platform_specific") do |s|
s.add_runtime_dependency "platform_specific" s.add_dependency "platform_specific"
s.platform = Bundler.local_platform s.platform = Bundler.local_platform
s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'" s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
end end

View File

@ -179,16 +179,16 @@ RSpec.describe "bundle install across platforms" do
build_gem "empyrean", "0.1.0" build_gem "empyrean", "0.1.0"
build_gem "coderay", "1.1.2" build_gem "coderay", "1.1.2"
build_gem "method_source", "0.9.0" build_gem "method_source", "0.9.0"
build_gem("spoon", "0.0.6") {|s| s.add_runtime_dependency "ffi" } build_gem("spoon", "0.0.6") {|s| s.add_dependency "ffi" }
build_gem "pry", "0.11.3" do |s| build_gem "pry", "0.11.3" do |s|
s.platform = "java" s.platform = "java"
s.add_runtime_dependency "coderay", "~> 1.1.0" s.add_dependency "coderay", "~> 1.1.0"
s.add_runtime_dependency "method_source", "~> 0.9.0" s.add_dependency "method_source", "~> 0.9.0"
s.add_runtime_dependency "spoon", "~> 0.0" s.add_dependency "spoon", "~> 0.0"
end end
build_gem "pry", "0.11.3" do |s| build_gem "pry", "0.11.3" do |s|
s.add_runtime_dependency "coderay", "~> 1.1.0" s.add_dependency "coderay", "~> 1.1.0"
s.add_runtime_dependency "method_source", "~> 0.9.0" s.add_dependency "method_source", "~> 0.9.0"
end end
build_gem("ffi", "1.9.23") {|s| s.platform = "java" } build_gem("ffi", "1.9.23") {|s| s.platform = "java" }
build_gem("ffi", "1.9.23") build_gem("ffi", "1.9.23")
@ -332,11 +332,11 @@ RSpec.describe "bundle install across platforms" do
update_repo2 do update_repo2 do
build_gem "fspath", "3" build_gem "fspath", "3"
build_gem "image_optim_pack", "1.2.3" do |s| build_gem "image_optim_pack", "1.2.3" do |s|
s.add_runtime_dependency "fspath", ">= 2.1", "< 4" s.add_dependency "fspath", ">= 2.1", "< 4"
end end
build_gem "image_optim_pack", "1.2.3" do |s| build_gem "image_optim_pack", "1.2.3" do |s|
s.platform = "universal-darwin" s.platform = "universal-darwin"
s.add_runtime_dependency "fspath", "< 4", ">= 2.1" s.add_dependency "fspath", "< 4", ">= 2.1"
end end
end end

View File

@ -166,7 +166,7 @@ RSpec.describe "bundle install with specific platforms" do
build_gem("libv8", "8.4.255.0") {|s| s.platform = "universal-darwin" } build_gem("libv8", "8.4.255.0") {|s| s.platform = "universal-darwin" }
build_gem("mini_racer", "1.0.0") do |s| build_gem("mini_racer", "1.0.0") do |s|
s.add_runtime_dependency "libv8" s.add_dependency "libv8"
end end
end end
@ -483,12 +483,12 @@ RSpec.describe "bundle install with specific platforms" do
it "automatically fixes the lockfile if RUBY platform is locked and some gem has no RUBY variant available" do it "automatically fixes the lockfile if RUBY platform is locked and some gem has no RUBY variant available" do
build_repo4 do build_repo4 do
build_gem("sorbet-static-and-runtime", "0.5.10160") do |s| build_gem("sorbet-static-and-runtime", "0.5.10160") do |s|
s.add_runtime_dependency "sorbet", "= 0.5.10160" s.add_dependency "sorbet", "= 0.5.10160"
s.add_runtime_dependency "sorbet-runtime", "= 0.5.10160" s.add_dependency "sorbet-runtime", "= 0.5.10160"
end end
build_gem("sorbet", "0.5.10160") do |s| build_gem("sorbet", "0.5.10160") do |s|
s.add_runtime_dependency "sorbet-static", "= 0.5.10160" s.add_dependency "sorbet-static", "= 0.5.10160"
end end
build_gem("sorbet-runtime", "0.5.10160") build_gem("sorbet-runtime", "0.5.10160")
@ -635,12 +635,12 @@ RSpec.describe "bundle install with specific platforms" do
it "automatically fixes the lockfile if only RUBY platform is locked and some gem has no RUBY variant available" do it "automatically fixes the lockfile if only RUBY platform is locked and some gem has no RUBY variant available" do
build_repo4 do build_repo4 do
build_gem("sorbet-static-and-runtime", "0.5.10160") do |s| build_gem("sorbet-static-and-runtime", "0.5.10160") do |s|
s.add_runtime_dependency "sorbet", "= 0.5.10160" s.add_dependency "sorbet", "= 0.5.10160"
s.add_runtime_dependency "sorbet-runtime", "= 0.5.10160" s.add_dependency "sorbet-runtime", "= 0.5.10160"
end end
build_gem("sorbet", "0.5.10160") do |s| build_gem("sorbet", "0.5.10160") do |s|
s.add_runtime_dependency "sorbet-static", "= 0.5.10160" s.add_dependency "sorbet-static", "= 0.5.10160"
end end
build_gem("sorbet-runtime", "0.5.10160") build_gem("sorbet-runtime", "0.5.10160")
@ -848,7 +848,7 @@ RSpec.describe "bundle install with specific platforms" do
simulate_platform "x86_64-linux" do simulate_platform "x86_64-linux" do
build_repo4 do build_repo4 do
build_gem("ibandit", "0.7.0") do |s| build_gem("ibandit", "0.7.0") do |s|
s.add_runtime_dependency "i18n", "~> 0.7.0" s.add_dependency "i18n", "~> 0.7.0"
end end
build_gem("i18n", "0.7.0.beta1") build_gem("i18n", "0.7.0.beta1")
@ -1123,7 +1123,7 @@ RSpec.describe "bundle install with specific platforms" do
simulate_platform "x86_64-linux" do simulate_platform "x86_64-linux" do
build_repo4 do build_repo4 do
build_gem("sorbet", "0.5.10160") do |s| build_gem("sorbet", "0.5.10160") do |s|
s.add_runtime_dependency "sorbet-static", "= 0.5.10160" s.add_dependency "sorbet-static", "= 0.5.10160"
end end
build_gem("sorbet-static", "0.5.10160") do |s| build_gem("sorbet-static", "0.5.10160") do |s|
@ -1546,7 +1546,7 @@ RSpec.describe "bundle install with specific platforms" do
build_gem("facter", "2.4.6") build_gem("facter", "2.4.6")
build_gem("facter", "2.4.6") do |s| build_gem("facter", "2.4.6") do |s|
s.platform = "universal-darwin" s.platform = "universal-darwin"
s.add_runtime_dependency "CFPropertyList" s.add_dependency "CFPropertyList"
end end
build_gem("CFPropertyList") build_gem("CFPropertyList")
end end

View File

@ -61,7 +61,7 @@ RSpec.describe "compact index api" do
it "should handle case sensitivity conflicts" do it "should handle case sensitivity conflicts" do
build_repo4(build_compact_index: false) do build_repo4(build_compact_index: false) do
build_gem "myrack", "1.0" do |s| build_gem "myrack", "1.0" do |s|
s.add_runtime_dependency("Myrack", "0.1") s.add_dependency("Myrack", "0.1")
end end
build_gem "Myrack", "0.1" build_gem "Myrack", "0.1"
end end

View File

@ -41,7 +41,7 @@ RSpec.describe "bundle install" do
spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.name = "myrack" s.name = "myrack"
s.version = "1.0.0" s.version = "1.0.0"
s.add_runtime_dependency "activesupport", "2.3.2" s.add_dependency "activesupport", "2.3.2"
end end
f.write spec.to_ruby f.write spec.to_ruby
end end

View File

@ -1305,7 +1305,7 @@ end
s.files = Dir["lib/**/*.rb"] s.files = Dir["lib/**/*.rb"]
s.author = 'no one' s.author = 'no one'
s.add_runtime_dependency 'digest' s.add_dependency 'digest'
end end
G G
end end

View File

@ -182,7 +182,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.download "a", 2 do |s| fetcher.download "a", 2 do |s|
s.executables = %w[a] s.executables = %w[a]
s.files = %w[bin/a lib/a.rb] s.files = %w[bin/a lib/a.rb]
s.add_runtime_dependency "with_platform" s.add_dependency "with_platform"
write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| write_file File.join(*%W[gems #{s.original_name} bin a]) do |f|
f << 'require "with_platform"' << "\n" f << 'require "with_platform"' << "\n"
@ -222,7 +222,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.download "a", 2 do |s| fetcher.download "a", 2 do |s|
s.executables = %w[a] s.executables = %w[a]
s.files = %w[bin/a lib/a.rb] s.files = %w[bin/a lib/a.rb]
s.add_runtime_dependency "with_platform" s.add_dependency "with_platform"
s.platform = Gem::Platform.local.to_s s.platform = Gem::Platform.local.to_s
write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| write_file File.join(*%W[gems #{s.original_name} bin a]) do |f|
@ -234,7 +234,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.download "a", 2 do |s| fetcher.download "a", 2 do |s|
s.executables = %w[a] s.executables = %w[a]
s.files = %w[bin/a lib/a.rb extconf.rb] s.files = %w[bin/a lib/a.rb extconf.rb]
s.add_runtime_dependency "with_platform" s.add_dependency "with_platform"
write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| write_file File.join(*%W[gems #{s.original_name} bin a]) do |f|
f << 'require "with_platform"' << "\n" f << 'require "with_platform"' << "\n"
@ -261,7 +261,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.download "with_platform", 2 do |s| fetcher.download "with_platform", 2 do |s|
s.files = %w[lib/with_platform.rb] s.files = %w[lib/with_platform.rb]
s.add_runtime_dependency "sometimes_used" s.add_dependency "sometimes_used"
end end
fetcher.download "sometimes_used", 2 do |s| fetcher.download "sometimes_used", 2 do |s|
@ -677,7 +677,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.gem "a", 1 do |s| fetcher.gem "a", 1 do |s|
s.executables = %w[] s.executables = %w[]
s.files = %w[lib/a.rb] s.files = %w[lib/a.rb]
s.add_runtime_dependency "b" s.add_dependency "b"
end end
fetcher.gem "b", 1 do |s| fetcher.gem "b", 1 do |s|
@ -711,7 +711,7 @@ class TestGemCommandsExecCommand < Gem::TestCase
fetcher.download "a", 2 do |s| fetcher.download "a", 2 do |s|
s.executables = %w[a] s.executables = %w[a]
s.files = %w[bin/a lib/a.rb] s.files = %w[bin/a lib/a.rb]
s.add_runtime_dependency "b" s.add_dependency "b"
write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| write_file File.join(*%W[gems #{s.original_name} bin a]) do |f|
f << "Gem.ui.say #{s.original_name.dump}" f << "Gem.ui.say #{s.original_name.dump}"

View File

@ -9,11 +9,11 @@ class TestGemCommandsLockCommand < Gem::TestCase
@a1 = quick_gem "a", "1" @a1 = quick_gem "a", "1"
@b1 = quick_gem "b", "1" do |s| @b1 = quick_gem "b", "1" do |s|
s.add_runtime_dependency "a" s.add_dependency "a"
end end
@d1 = quick_gem "d", "1" do |s| @d1 = quick_gem "d", "1" do |s|
s.add_runtime_dependency "z" s.add_dependency "z"
end end
@cmd = Gem::Commands::LockCommand.new @cmd = Gem::Commands::LockCommand.new

View File

@ -44,7 +44,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
def test_gempspec_with_multiple_runtime_deps def test_gempspec_with_multiple_runtime_deps
save_gemspec "foo", "1.0" do |s| save_gemspec "foo", "1.0" do |s|
s.add_runtime_dependency "bar", ">= 1.6.0", "< 1.6.4" s.add_dependency "bar", ">= 1.6.0", "< 1.6.4"
end end
@gda.gemspec @gda.gemspec
assert_equal %w[foo bar].sort, @set.dependencies.map(&:name).sort assert_equal %w[foo bar].sort, @set.dependencies.map(&:name).sort

View File

@ -571,7 +571,7 @@ class TestGemResolver < Gem::TestCase
def test_raises_and_reports_an_implicit_request_properly def test_raises_and_reports_an_implicit_request_properly
a1 = util_spec "a", "1" do |s| a1 = util_spec "a", "1" do |s|
s.add_runtime_dependency "b", "= 2" s.add_dependency "b", "= 2"
end end
ad = make_dep "a", "= 1" ad = make_dep "a", "= 1"

View File

@ -1833,7 +1833,7 @@ dependencies: []
end end
def test_for_cache def test_for_cache
@a2.add_runtime_dependency "b", "1" @a2.add_dependency "b", "1"
@a2.dependencies.first.instance_variable_set :@type, nil @a2.dependencies.first.instance_variable_set :@type, nil
@a2.required_rubygems_version = Gem::Requirement.new "> 0" @a2.required_rubygems_version = Gem::Requirement.new "> 0"
@a2.test_files = %w[test/test_b.rb] @a2.test_files = %w[test/test_b.rb]
@ -2265,7 +2265,7 @@ dependencies: []
end end
def test_to_ruby def test_to_ruby
@a2.add_runtime_dependency "b", "1" @a2.add_dependency "b", "1"
@a2.dependencies.first.instance_variable_set :@type, nil @a2.dependencies.first.instance_variable_set :@type, nil
@a2.required_rubygems_version = Gem::Requirement.new "> 0" @a2.required_rubygems_version = Gem::Requirement.new "> 0"
@a2.require_paths << "other" @a2.require_paths << "other"
@ -2337,7 +2337,7 @@ end
end end
def test_to_ruby_for_cache def test_to_ruby_for_cache
@a2.add_runtime_dependency "b", "1" @a2.add_dependency "b", "1"
@a2.dependencies.first.instance_variable_set :@type, nil @a2.dependencies.first.instance_variable_set :@type, nil
@a2.required_rubygems_version = Gem::Requirement.new "> 0" @a2.required_rubygems_version = Gem::Requirement.new "> 0"
@a2.installed_by_version = Gem.rubygems_version @a2.installed_by_version = Gem.rubygems_version
@ -2760,7 +2760,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
Dir.chdir @tempdir do Dir.chdir @tempdir do
@a1.version = "1.0.0.beta.1" @a1.version = "1.0.0.beta.1"
@a1.add_runtime_dependency "b", "~> 1.2.0.beta.1" @a1.add_dependency "b", "~> 1.2.0.beta.1"
use_ui @ui do use_ui @ui do
@a1.validate @a1.validate
@ -2774,7 +2774,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
util_setup_validate util_setup_validate
Dir.chdir @tempdir do Dir.chdir @tempdir do
@a1.add_runtime_dependency @a1.name, "1" @a1.add_dependency @a1.name, "1"
use_ui @ui do use_ui @ui do
@a1.validate @a1.validate
@ -2807,7 +2807,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
Dir.chdir @tempdir do Dir.chdir @tempdir do
@a1.extensions = ["Rakefile"] @a1.extensions = ["Rakefile"]
@a1.add_runtime_dependency "rake" @a1.add_dependency "rake"
File.write File.join(@tempdir, "Rakefile"), "" File.write File.join(@tempdir, "Rakefile"), ""
use_ui @ui do use_ui @ui do
@ -3077,7 +3077,7 @@ Please report a bug if this causes problems.
def test_duplicate_runtime_dependency def test_duplicate_runtime_dependency
expected = "WARNING: duplicated b dependency [\"~> 3.0\", \"~> 3.0\"]\n" expected = "WARNING: duplicated b dependency [\"~> 3.0\", \"~> 3.0\"]\n"
out, err = capture_output do out, err = capture_output do
@a1.add_runtime_dependency "b", "~> 3.0", "~> 3.0" @a1.add_dependency "b", "~> 3.0", "~> 3.0"
end end
assert_empty out assert_empty out
assert_equal(expected, err) assert_equal(expected, err)

View File

@ -403,7 +403,7 @@ create_makefile '#{@spec.name}'
def test_uninstall_not_ok def test_uninstall_not_ok
quick_gem "z" do |s| quick_gem "z" do |s|
s.add_runtime_dependency @spec.name s.add_dependency @spec.name
end end
uninstaller = Gem::Uninstaller.new @spec.name uninstaller = Gem::Uninstaller.new @spec.name