mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[rubygems/rubygems] Put bundler gemspec stub at the right place
So that it's found when needed, rather than dynamically modifying
loaded stubs and thus messing with RubyGems internals.
cd3e7cb9e5
This commit is contained in:
parent
668e78f01b
commit
ac56e5c1ab
1 changed files with 28 additions and 25 deletions
|
@ -615,7 +615,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_use_gemdeps
|
def test_self_use_gemdeps
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("-") do
|
with_rubygems_gemdeps("-") do
|
||||||
FileUtils.mkdir_p "detect/a/b"
|
FileUtils.mkdir_p "detect/a/b"
|
||||||
FileUtils.mkdir_p "detect/a/Isolate"
|
FileUtils.mkdir_p "detect/a/Isolate"
|
||||||
|
@ -775,7 +775,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_find_files_with_gemfile
|
def test_self_find_files_with_gemfile
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
cwd = File.expand_path("test/rubygems", PROJECT_DIR)
|
cwd = File.expand_path("test/rubygems", PROJECT_DIR)
|
||||||
actual_load_path = $LOAD_PATH.unshift(cwd).dup
|
actual_load_path = $LOAD_PATH.unshift(cwd).dup
|
||||||
|
|
||||||
|
@ -1635,7 +1635,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_activation_of_specific_gemdeps_file
|
def test_auto_activation_of_specific_gemdeps_file
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
a = util_spec "a", "1", nil, "lib/a.rb"
|
a = util_spec "a", "1", nil, "lib/a.rb"
|
||||||
b = util_spec "b", "1", nil, "lib/b.rb"
|
b = util_spec "b", "1", nil, "lib/b.rb"
|
||||||
c = util_spec "c", "1", nil, "lib/c.rb"
|
c = util_spec "c", "1", nil, "lib/c.rb"
|
||||||
|
@ -1659,7 +1659,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_auto_activation_of_used_gemdeps_file
|
def test_auto_activation_of_used_gemdeps_file
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
a = util_spec "a", "1", nil, "lib/a.rb"
|
a = util_spec "a", "1", nil, "lib/a.rb"
|
||||||
b = util_spec "b", "1", nil, "lib/b.rb"
|
b = util_spec "b", "1", nil, "lib/b.rb"
|
||||||
c = util_spec "c", "1", nil, "lib/c.rb"
|
c = util_spec "c", "1", nil, "lib/c.rb"
|
||||||
|
@ -1691,7 +1691,9 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_looks_for_gemdeps_files_automatically_from_binstubs
|
def test_looks_for_gemdeps_files_automatically_from_binstubs
|
||||||
with_local_bundler do
|
path = File.join(@tempdir, "gd-tmp")
|
||||||
|
|
||||||
|
with_local_bundler_at(path) do
|
||||||
a = util_spec "a", "1" do |s|
|
a = util_spec "a", "1" do |s|
|
||||||
s.executables = %w[foo]
|
s.executables = %w[foo]
|
||||||
s.bindir = "exe"
|
s.bindir = "exe"
|
||||||
|
@ -1706,7 +1708,6 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
install_specs a, b, c
|
install_specs a, b, c
|
||||||
|
|
||||||
path = File.join(@tempdir, "gd-tmp")
|
|
||||||
install_gem a, :install_dir => path
|
install_gem a, :install_dir => path
|
||||||
install_gem b, :install_dir => path
|
install_gem b, :install_dir => path
|
||||||
install_gem c, :install_dir => path
|
install_gem c, :install_dir => path
|
||||||
|
@ -1740,7 +1741,9 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir
|
def test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir
|
||||||
with_local_bundler do
|
path = File.join(@tempdir, "gd-tmp")
|
||||||
|
|
||||||
|
with_local_bundler_at(path) do
|
||||||
pend "IO.popen has issues on JRuby when passed :chdir" if Gem.java_platform?
|
pend "IO.popen has issues on JRuby when passed :chdir" if Gem.java_platform?
|
||||||
|
|
||||||
a = util_spec "a", "1" do |s|
|
a = util_spec "a", "1" do |s|
|
||||||
|
@ -1757,7 +1760,6 @@ class TestGem < Gem::TestCase
|
||||||
|
|
||||||
install_specs a, b, c
|
install_specs a, b, c
|
||||||
|
|
||||||
path = File.join(@tempdir, "gd-tmp")
|
|
||||||
install_gem a, :install_dir => path
|
install_gem a, :install_dir => path
|
||||||
install_gem b, :install_dir => path
|
install_gem b, :install_dir => path
|
||||||
install_gem c, :install_dir => path
|
install_gem c, :install_dir => path
|
||||||
|
@ -1835,7 +1837,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps
|
def test_use_gemdeps
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
gem_deps_file = "gem.deps.rb".tap(&Gem::UNTAINT)
|
gem_deps_file = "gem.deps.rb".tap(&Gem::UNTAINT)
|
||||||
spec = util_spec "a", 1
|
spec = util_spec "a", 1
|
||||||
install_specs spec
|
install_specs spec
|
||||||
|
@ -1857,7 +1859,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_ENV
|
def test_use_gemdeps_ENV
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps(nil) do
|
with_rubygems_gemdeps(nil) do
|
||||||
spec = util_spec "a", 1
|
spec = util_spec "a", 1
|
||||||
|
|
||||||
|
@ -1875,7 +1877,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_argument_missing
|
def test_use_gemdeps_argument_missing
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raise ArgumentError do
|
||||||
Gem.use_gemdeps "gem.deps.rb"
|
Gem.use_gemdeps "gem.deps.rb"
|
||||||
end
|
end
|
||||||
|
@ -1886,7 +1888,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_argument_missing_match_ENV
|
def test_use_gemdeps_argument_missing_match_ENV
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("gem.deps.rb") do
|
with_rubygems_gemdeps("gem.deps.rb") do
|
||||||
e = assert_raise ArgumentError do
|
e = assert_raise ArgumentError do
|
||||||
Gem.use_gemdeps "gem.deps.rb"
|
Gem.use_gemdeps "gem.deps.rb"
|
||||||
|
@ -1899,7 +1901,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_automatic
|
def test_use_gemdeps_automatic
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("-") do
|
with_rubygems_gemdeps("-") do
|
||||||
spec = util_spec "a", 1
|
spec = util_spec "a", 1
|
||||||
install_specs spec
|
install_specs spec
|
||||||
|
@ -1919,7 +1921,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_automatic_missing
|
def test_use_gemdeps_automatic_missing
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("-") do
|
with_rubygems_gemdeps("-") do
|
||||||
Gem.use_gemdeps
|
Gem.use_gemdeps
|
||||||
|
|
||||||
|
@ -1929,7 +1931,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_disabled
|
def test_use_gemdeps_disabled
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("") do
|
with_rubygems_gemdeps("") do
|
||||||
spec = util_spec "a", 1
|
spec = util_spec "a", 1
|
||||||
|
|
||||||
|
@ -1947,7 +1949,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_missing_gem
|
def test_use_gemdeps_missing_gem
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("x") do
|
with_rubygems_gemdeps("x") do
|
||||||
File.open "x", "w" do |io|
|
File.open "x", "w" do |io|
|
||||||
io.write 'gem "a"'
|
io.write 'gem "a"'
|
||||||
|
@ -1971,7 +1973,7 @@ You may need to `bundle install` to install missing gems
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_use_gemdeps_specific
|
def test_use_gemdeps_specific
|
||||||
with_local_bundler do
|
with_local_bundler_at(Gem.dir) do
|
||||||
with_rubygems_gemdeps("x") do
|
with_rubygems_gemdeps("x") do
|
||||||
spec = util_spec "a", 1
|
spec = util_spec "a", 1
|
||||||
install_specs spec
|
install_specs spec
|
||||||
|
@ -2121,17 +2123,18 @@ You may need to `bundle install` to install missing gems
|
||||||
ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps
|
ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_local_bundler
|
def with_local_bundler_at(path)
|
||||||
# If bundler gemspec exists, add to stubs
|
require "bundler"
|
||||||
|
|
||||||
|
# If bundler gemspec exists, pretend it's installed
|
||||||
bundler_gemspec = File.expand_path("../../bundler/bundler.gemspec", __dir__)
|
bundler_gemspec = File.expand_path("../../bundler/bundler.gemspec", __dir__)
|
||||||
if File.exist?(bundler_gemspec)
|
if File.exist?(bundler_gemspec)
|
||||||
Gem::Specification.dirs.unshift File.dirname(bundler_gemspec)
|
target_gemspec_location = "#{path}/specifications/bundler-#{Bundler::VERSION}.gemspec"
|
||||||
Gem::Specification.class_variable_set :@@stubs, nil
|
|
||||||
Gem::Specification.stubs
|
|
||||||
Gem::Specification.dirs.shift
|
|
||||||
end
|
|
||||||
|
|
||||||
require "bundler"
|
FileUtils.mkdir_p File.dirname(target_gemspec_location)
|
||||||
|
|
||||||
|
File.write target_gemspec_location, Gem::Specification.load(bundler_gemspec).to_ruby_for_cache
|
||||||
|
end
|
||||||
|
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue