mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Merge RubyGems-3.4.14 and Bundler-2.4.14
This commit is contained in:
parent
1b1a5b2984
commit
a36c836433
29 changed files with 258 additions and 87 deletions
|
@ -210,9 +210,10 @@ module Bundler
|
|||
end
|
||||
|
||||
def frozen_bundle?
|
||||
frozen = settings[:deployment]
|
||||
frozen ||= settings[:frozen]
|
||||
frozen
|
||||
frozen = settings[:frozen]
|
||||
return frozen unless frozen.nil?
|
||||
|
||||
settings[:deployment]
|
||||
end
|
||||
|
||||
def locked_gems
|
||||
|
|
|
@ -217,6 +217,7 @@ module Bundler
|
|||
rescue BundlerError => e
|
||||
@resolve = nil
|
||||
@resolver = nil
|
||||
@resolution_packages = nil
|
||||
@specs = nil
|
||||
@gem_version_promoter = nil
|
||||
|
||||
|
@ -361,10 +362,8 @@ module Bundler
|
|||
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
|
||||
|
||||
unless explicit_flag
|
||||
suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
|
||||
"bundle config unset frozen"
|
||||
elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
|
||||
"bundle config unset deployment"
|
||||
suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
|
||||
"bundle config set frozen false"
|
||||
end
|
||||
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
|
||||
"freeze \nby running `#{suggested_command}`." if suggested_command
|
||||
|
@ -886,7 +885,8 @@ module Bundler
|
|||
if preserve_unknown_sections
|
||||
sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
|
||||
sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
|
||||
sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
|
||||
sections_to_ignore << LockfileParser::RUBY
|
||||
sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
|
||||
pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
|
||||
whitespace_cleanup = /\n{2,}/
|
||||
current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
|
||||
|
|
|
@ -90,7 +90,7 @@ module Bundler
|
|||
|
||||
Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
|
||||
|
||||
lock unless Bundler.frozen_bundle?
|
||||
lock
|
||||
Standalone.new(options[:standalone], @definition).generate if options[:standalone]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ module Bundler
|
|||
KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
|
||||
|
||||
ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
|
||||
deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
|
||||
|
||||
def self.sections_in_lockfile(lockfile_contents)
|
||||
lockfile_contents.scan(/^\w[\w ]*$/).uniq
|
||||
|
|
|
@ -219,7 +219,6 @@ module Bundler
|
|||
def path
|
||||
configs.each do |_level, settings|
|
||||
path = value_for("path", settings)
|
||||
path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
|
||||
path_system = value_for("path.system", settings)
|
||||
disabled_shared_gems = value_for("disable_shared_gems", settings)
|
||||
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
|
||||
|
@ -227,7 +226,9 @@ module Bundler
|
|||
return Path.new(path, system_path)
|
||||
end
|
||||
|
||||
Path.new(nil, false)
|
||||
path = "vendor/bundle" if self[:deployment]
|
||||
|
||||
Path.new(path, false)
|
||||
end
|
||||
|
||||
Path = Struct.new(:explicit_path, :system_path) do
|
||||
|
|
|
@ -10,7 +10,7 @@ module Bundler
|
|||
# Ask for X gems per API request
|
||||
API_REQUEST_SIZE = 50
|
||||
|
||||
attr_reader :remotes, :caches
|
||||
attr_reader :remotes
|
||||
|
||||
def initialize(options = {})
|
||||
@options = options
|
||||
|
@ -19,11 +19,14 @@ module Bundler
|
|||
@allow_remote = false
|
||||
@allow_cached = false
|
||||
@allow_local = options["allow_local"] || false
|
||||
@caches = [cache_path, *Bundler.rubygems.gem_cache]
|
||||
|
||||
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
|
||||
end
|
||||
|
||||
def caches
|
||||
@caches ||= [cache_path, *Bundler.rubygems.gem_cache]
|
||||
end
|
||||
|
||||
def local_only!
|
||||
@specs = nil
|
||||
@allow_local = true
|
||||
|
@ -324,9 +327,9 @@ module Bundler
|
|||
|
||||
def cached_path(spec)
|
||||
global_cache_path = download_cache_path(spec)
|
||||
@caches << global_cache_path if global_cache_path
|
||||
caches << global_cache_path if global_cache_path
|
||||
|
||||
possibilities = @caches.map {|p| package_path(p, spec) }
|
||||
possibilities = caches.map {|p| package_path(p, spec) }
|
||||
possibilities.find {|p| File.exist?(p) }
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
|
|||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||
spec.files = Dir.chdir(__dir__) do
|
||||
`git ls-files -z`.split("\x0").reject do |f|
|
||||
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
||||
(File.expand_path(f) == __FILE__) ||
|
||||
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
||||
end
|
||||
end
|
||||
spec.bindir = "exe"
|
||||
|
|
|
@ -162,7 +162,7 @@ module Bundler::PubGrub
|
|||
def resolve_conflict(incompatibility)
|
||||
logger.info { "conflict: #{incompatibility}" }
|
||||
|
||||
new_incompatibility = false
|
||||
new_incompatibility = nil
|
||||
|
||||
while !incompatibility.failure?
|
||||
most_recent_term = nil
|
||||
|
@ -204,7 +204,7 @@ module Bundler::PubGrub
|
|||
solution.backtrack(previous_level)
|
||||
|
||||
if new_incompatibility
|
||||
add_incompatibility(incompatibility)
|
||||
add_incompatibility(new_incompatibility)
|
||||
end
|
||||
|
||||
return incompatibility
|
||||
|
@ -219,9 +219,14 @@ module Bundler::PubGrub
|
|||
new_terms << difference.invert
|
||||
end
|
||||
|
||||
incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
|
||||
new_incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
|
||||
|
||||
new_incompatibility = true
|
||||
if incompatibility.to_s == new_incompatibility.to_s
|
||||
logger.info { "!! failed to resolve conflicts, this shouldn't have happened" }
|
||||
break
|
||||
end
|
||||
|
||||
incompatibility = new_incompatibility
|
||||
|
||||
partially = difference ? " partially" : ""
|
||||
logger.info { "! #{most_recent_term} is#{partially} satisfied by #{most_recent_satisfier.term}" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: false
|
||||
|
||||
module Bundler
|
||||
VERSION = "2.4.13".freeze
|
||||
VERSION = "2.4.14".freeze
|
||||
|
||||
def self.bundler_major_version
|
||||
@bundler_major_version ||= VERSION.split(".").first.to_i
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
require "rbconfig"
|
||||
|
||||
module Gem
|
||||
VERSION = "3.4.13"
|
||||
VERSION = "3.4.14"
|
||||
end
|
||||
|
||||
# Must be first since it unloads the prelude from 1.9.2
|
||||
|
|
|
@ -342,6 +342,8 @@ class Gem::Installer
|
|||
|
||||
Gem::Specification.add_spec(spec)
|
||||
|
||||
load_plugin
|
||||
|
||||
run_post_install_hooks
|
||||
|
||||
spec
|
||||
|
@ -1002,4 +1004,17 @@ TEXT
|
|||
""
|
||||
end
|
||||
end
|
||||
|
||||
def load_plugin
|
||||
specs = Gem::Specification.find_all_by_name(spec.name)
|
||||
# If old version already exists, this plugin isn't loaded
|
||||
# immediately. It's for avoiding a case that multiple versions
|
||||
# are loaded at the same time.
|
||||
return unless specs.size == 1
|
||||
|
||||
plugin_files = spec.plugins.map do |plugin|
|
||||
File.join(@plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}")
|
||||
end
|
||||
Gem.load_plugin_files(plugin_files)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,11 +10,11 @@ end
|
|||
base_path = File.expand_path("../lib", __dir__)
|
||||
|
||||
if File.exist?(base_path)
|
||||
require_relative "../lib/bundler"
|
||||
else
|
||||
require "bundler"
|
||||
$LOAD_PATH.unshift(base_path)
|
||||
end
|
||||
|
||||
require "bundler"
|
||||
|
||||
if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.7.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
|
||||
Bundler.ui.warn \
|
||||
"Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
|
||||
|
@ -24,18 +24,10 @@ if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::V
|
|||
"and silence this warning by running `gem update --system 3.2.3`"
|
||||
end
|
||||
|
||||
if File.exist?(base_path)
|
||||
require_relative "../lib/bundler/friendly_errors"
|
||||
else
|
||||
require "bundler/friendly_errors"
|
||||
end
|
||||
|
||||
Bundler.with_friendly_errors do
|
||||
if File.exist?(base_path)
|
||||
require_relative "../lib/bundler/cli"
|
||||
else
|
||||
require "bundler/cli"
|
||||
end
|
||||
|
||||
# Allow any command to use --help flag to show help for that command
|
||||
help_flags = %w[--help -h]
|
||||
|
|
|
@ -638,6 +638,14 @@ RSpec.describe "bundle gem" do
|
|||
expect(bundler_gemspec.files).not_to include("#{gem_name}.gemspec")
|
||||
end
|
||||
|
||||
it "does not include the Gemfile file in files" do
|
||||
bundle "gem #{gem_name}"
|
||||
|
||||
bundler_gemspec = Bundler::GemHelper.new(bundled_app(gem_name), gem_name).gemspec
|
||||
|
||||
expect(bundler_gemspec.files).not_to include("Gemfile")
|
||||
end
|
||||
|
||||
it "runs rake without problems" do
|
||||
bundle "gem #{gem_name}"
|
||||
|
||||
|
|
|
@ -659,21 +659,21 @@ RSpec.describe "bundle update" do
|
|||
|
||||
expect(last_command).to be_failure
|
||||
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
|
||||
expect(err).to match(/freeze \nby running `bundle config unset deployment`./m)
|
||||
expect(err).to match(/freeze \nby running `bundle config set frozen false`./m)
|
||||
end
|
||||
|
||||
it "should suggest different command when frozen is set globally", :bundler => "< 3" do
|
||||
it "should fail loudly when frozen is set globally" do
|
||||
bundle "config set --global frozen 1"
|
||||
bundle "update", :all => true, :raise_on_error => false
|
||||
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
|
||||
and match(/freeze \nby running `bundle config unset frozen`./m)
|
||||
and match(/freeze \nby running `bundle config set frozen false`./m)
|
||||
end
|
||||
|
||||
it "should suggest different command when frozen is set globally", :bundler => "3" do
|
||||
it "should fail loudly when deployment is set globally" do
|
||||
bundle "config set --global deployment true"
|
||||
bundle "update", :all => true, :raise_on_error => false
|
||||
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
|
||||
and match(/freeze \nby running `bundle config unset deployment`./m)
|
||||
and match(/freeze \nby running `bundle config set frozen false`./m)
|
||||
end
|
||||
|
||||
it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
|
||||
|
@ -1451,6 +1451,31 @@ RSpec.describe "bundle update --bundler" do
|
|||
expect(out).to include("Using bundler 2.3.9")
|
||||
end
|
||||
end
|
||||
|
||||
it "prints an error when trying to update bundler in frozen mode" do
|
||||
system_gems "bundler-2.3.9"
|
||||
|
||||
gemfile <<~G
|
||||
source "#{file_uri_for(gem_repo2)}"
|
||||
G
|
||||
|
||||
lockfile <<-L
|
||||
GEM
|
||||
remote: #{file_uri_for(gem_repo2)}/
|
||||
specs:
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
||||
L
|
||||
|
||||
bundle "update --bundler=2.3.9", :env => { "BUNDLE_FROZEN" => "true" }
|
||||
expect(err).to include("Cannot write a changed lockfile while frozen")
|
||||
end
|
||||
end
|
||||
|
||||
# these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that.
|
||||
|
|
|
@ -39,6 +39,39 @@ RSpec.describe "install in deployment or frozen mode" do
|
|||
bundle :install
|
||||
expect(the_bundle).to include_gems "rack 1.0"
|
||||
end
|
||||
|
||||
it "installs gems by default to vendor/bundle" do
|
||||
bundle :lock
|
||||
bundle "install --deployment"
|
||||
expect(out).to include("vendor/bundle")
|
||||
end
|
||||
|
||||
it "installs gems to custom path if specified" do
|
||||
bundle :lock
|
||||
bundle "install --path vendor/bundle2 --deployment"
|
||||
expect(out).to include("vendor/bundle2")
|
||||
end
|
||||
|
||||
it "works with the --frozen flag" do
|
||||
bundle :lock
|
||||
bundle "install --frozen"
|
||||
end
|
||||
|
||||
it "explodes with the --deployment flag if you make a change and don't check in the lockfile" do
|
||||
bundle :lock
|
||||
gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
gem "rack"
|
||||
gem "rack-obama"
|
||||
G
|
||||
|
||||
bundle "install --deployment", :raise_on_error => false
|
||||
expect(err).to include("deployment mode")
|
||||
expect(err).to include("You have added to the Gemfile")
|
||||
expect(err).to include("* rack-obama")
|
||||
expect(err).not_to include("You have deleted from the Gemfile")
|
||||
expect(err).not_to include("You have changed in the Gemfile")
|
||||
end
|
||||
end
|
||||
|
||||
it "still works if you are not in the app directory and specify --gemfile" do
|
||||
|
@ -202,29 +235,35 @@ RSpec.describe "install in deployment or frozen mode" do
|
|||
bundle "install"
|
||||
end
|
||||
|
||||
it "installs gems by default to vendor/bundle", :bundler => "< 3" do
|
||||
bundle "install --deployment"
|
||||
it "installs gems by default to vendor/bundle" do
|
||||
bundle "config set deployment true"
|
||||
bundle "install"
|
||||
expect(out).to include("vendor/bundle")
|
||||
end
|
||||
|
||||
it "installs gems to custom path if specified", :bundler => "< 3" do
|
||||
bundle "install --path vendor/bundle2 --deployment"
|
||||
it "installs gems to custom path if specified" do
|
||||
bundle "config set path vendor/bundle2"
|
||||
bundle "config set deployment true"
|
||||
bundle "install"
|
||||
expect(out).to include("vendor/bundle2")
|
||||
end
|
||||
|
||||
it "works with the --deployment flag if you didn't change anything", :bundler => "< 3" do
|
||||
bundle "install --deployment"
|
||||
it "installs gems to custom path if specified, even when configured through ENV" do
|
||||
bundle "config set deployment true"
|
||||
bundle "install", :env => { "BUNDLE_PATH" => "vendor/bundle2" }
|
||||
expect(out).to include("vendor/bundle2")
|
||||
end
|
||||
|
||||
it "works with the --frozen flag if you didn't change anything", :bundler => "< 3" do
|
||||
bundle "install --frozen"
|
||||
it "works with the `frozen` setting" do
|
||||
bundle "config set frozen true"
|
||||
bundle "install"
|
||||
end
|
||||
|
||||
it "works with BUNDLE_FROZEN if you didn't change anything" do
|
||||
bundle :install, :env => { "BUNDLE_FROZEN" => "true" }
|
||||
end
|
||||
|
||||
it "explodes with the --deployment flag if you make a change and don't check in the lockfile" do
|
||||
it "explodes with the `deployment` setting if you make a change and don't check in the lockfile" do
|
||||
gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
gem "rack"
|
||||
|
@ -285,7 +324,7 @@ RSpec.describe "install in deployment or frozen mode" do
|
|||
expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
|
||||
end
|
||||
|
||||
it "can have --frozen set via an environment variable", :bundler => "< 3" do
|
||||
it "can have --frozen set via an environment variable" do
|
||||
gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
gem "rack"
|
||||
|
@ -317,13 +356,13 @@ RSpec.describe "install in deployment or frozen mode" do
|
|||
expect(err).not_to include("You have changed in the Gemfile")
|
||||
end
|
||||
|
||||
it "installs gems by default to vendor/bundle when deployment mode is set via an environment variable", :bundler => "< 3" do
|
||||
it "installs gems by default to vendor/bundle when deployment mode is set via an environment variable" do
|
||||
ENV["BUNDLE_DEPLOYMENT"] = "true"
|
||||
bundle "install"
|
||||
expect(out).to include("vendor/bundle")
|
||||
end
|
||||
|
||||
it "installs gems to custom path when deployment mode is set via an environment variable ", :bundler => "< 3" do
|
||||
it "installs gems to custom path when deployment mode is set via an environment variable " do
|
||||
ENV["BUNDLE_DEPLOYMENT"] = "true"
|
||||
ENV["BUNDLE_PATH"] = "vendor/bundle2"
|
||||
bundle "install"
|
||||
|
|
|
@ -1148,7 +1148,7 @@ RSpec.describe "bundle install with git sources" do
|
|||
it "gives a helpful error message when the remote branch no longer exists" do
|
||||
build_git "foo"
|
||||
|
||||
install_gemfile <<-G, :raise_on_error => false
|
||||
install_gemfile <<-G, :env => { "LANG" => "en" }, :raise_on_error => false
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :branch => "deadbeef"
|
||||
G
|
||||
|
|
|
@ -28,7 +28,7 @@ RSpec.describe "bundle lock with git gems" do
|
|||
gem 'foo', :git => "#{lib_path("foo-1.0")}", :branch => "bad"
|
||||
G
|
||||
|
||||
bundle "lock --update foo", :raise_on_error => false
|
||||
bundle "lock --update foo", :env => { "LANG" => "en" }, :raise_on_error => false
|
||||
|
||||
expect(err).to include("Revision bad does not exist in the repository")
|
||||
end
|
||||
|
|
|
@ -191,6 +191,31 @@ RSpec.describe "bundler/inline#gemfile" do
|
|||
expect(err).to be_empty
|
||||
end
|
||||
|
||||
it "installs subdependencies quietly if necessary when the install option is not set, and multiple sources used" do
|
||||
build_repo4 do
|
||||
build_gem "rack" do |s|
|
||||
s.add_dependency "rackdep"
|
||||
end
|
||||
|
||||
build_gem "rackdep", "1.0.0"
|
||||
end
|
||||
|
||||
script <<-RUBY
|
||||
gemfile do
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
source "#{file_uri_for(gem_repo4)}" do
|
||||
gem "rack"
|
||||
end
|
||||
end
|
||||
|
||||
require "rackdep"
|
||||
puts RACKDEP
|
||||
RUBY
|
||||
|
||||
expect(out).to eq("1.0.0")
|
||||
expect(err).to be_empty
|
||||
end
|
||||
|
||||
it "installs quietly from git if necessary when the install option is not set" do
|
||||
build_git "foo", "1.0.0"
|
||||
baz_ref = build_git("baz", "2.0.0").ref_for("HEAD")
|
||||
|
|
|
@ -302,7 +302,7 @@ module Spec
|
|||
def install_gem(path, default = false)
|
||||
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
|
||||
|
||||
args = "--no-document --ignore-dependencies"
|
||||
args = "--no-document --ignore-dependencies --verbose --local"
|
||||
args += " --default --install-dir #{system_gem_path}" if default
|
||||
|
||||
gem_command "install #{args} '#{path}'"
|
||||
|
|
|
@ -1435,6 +1435,8 @@ class TestGem < Gem::TestCase
|
|||
def test_load_plugins
|
||||
plugin_path = File.join "lib", "rubygems_plugin.rb"
|
||||
|
||||
foo1_plugin_path = nil
|
||||
foo2_plugin_path = nil
|
||||
Dir.chdir @tempdir do
|
||||
FileUtils.mkdir_p "lib"
|
||||
File.open plugin_path, "w" do |fp|
|
||||
|
@ -1444,17 +1446,22 @@ class TestGem < Gem::TestCase
|
|||
foo1 = util_spec "foo", "1" do |s|
|
||||
s.files << plugin_path
|
||||
end
|
||||
foo1_plugin_path = File.join(foo1.gem_dir, plugin_path)
|
||||
|
||||
install_gem foo1
|
||||
|
||||
foo2 = util_spec "foo", "2" do |s|
|
||||
s.files << plugin_path
|
||||
end
|
||||
foo2_plugin_path = File.join(foo2.gem_dir, plugin_path)
|
||||
|
||||
install_gem foo2
|
||||
end
|
||||
|
||||
Gem::Specification.reset
|
||||
PLUGINS_LOADED.clear
|
||||
$LOADED_FEATURES.delete(foo1_plugin_path)
|
||||
$LOADED_FEATURES.delete(foo2_plugin_path)
|
||||
|
||||
gem "foo"
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||
fp.puts "puts __FILE__"
|
||||
end
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |fp|
|
||||
fp.puts "puts __FILE__"
|
||||
fp.puts "# do nothing"
|
||||
end
|
||||
write_file File.join(@tempdir, "bin", "foo") do |fp|
|
||||
fp.puts "#!/usr/bin/ruby"
|
||||
|
|
|
@ -433,7 +433,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
s.files = %W[lib/rubygems_plugin.rb]
|
||||
end
|
||||
write_file File.join @tempdir, "lib", "rubygems_plugin.rb" do |f|
|
||||
f.puts "require '#{gem.plugins.first}'"
|
||||
f.puts "# do nothing"
|
||||
end
|
||||
install_gem gem
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@ require_relative "helper"
|
|||
|
||||
class TestGemGemRunner < Gem::TestCase
|
||||
def setup
|
||||
@orig_gem_home = ENV["GEM_HOME"]
|
||||
ENV["GEM_HOME"] = @gemhome
|
||||
|
||||
require "rubygems/command"
|
||||
@orig_args = Gem::Command.build_args
|
||||
@orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup
|
||||
|
@ -13,18 +10,21 @@ class TestGemGemRunner < Gem::TestCase
|
|||
|
||||
super
|
||||
|
||||
@orig_gem_home = ENV["GEM_HOME"]
|
||||
ENV["GEM_HOME"] = @gemhome
|
||||
|
||||
require "rubygems/gem_runner"
|
||||
@runner = Gem::GemRunner.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
ENV["GEM_HOME"] = @orig_gem_home
|
||||
|
||||
super
|
||||
|
||||
Gem::Command.build_args = @orig_args
|
||||
Gem::Command.specific_extra_args_hash = @orig_specific_extra_args
|
||||
Gem::Command.extra_args = @orig_extra_args
|
||||
|
||||
ENV["GEM_HOME"] = @orig_gem_home
|
||||
end
|
||||
|
||||
def test_do_configuration
|
||||
|
|
|
@ -766,7 +766,7 @@ gem 'other', version
|
|||
def test_generate_plugins
|
||||
installer = util_setup_installer do |spec|
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
spec.files += %w[lib/rubygems_plugin.rb]
|
||||
|
@ -853,11 +853,59 @@ gem 'other', version
|
|||
refute_includes File.read(build_root_path), build_root
|
||||
end
|
||||
|
||||
class << self
|
||||
attr_accessor :plugin_loaded
|
||||
attr_accessor :post_install_is_called
|
||||
end
|
||||
|
||||
def test_use_plugin_immediately
|
||||
self.class.plugin_loaded = false
|
||||
self.class.post_install_is_called = false
|
||||
spec_version = nil
|
||||
plugin_path = nil
|
||||
installer = util_setup_installer do |spec|
|
||||
spec_version = spec.version
|
||||
plugin_path = File.join("lib", "rubygems_plugin.rb")
|
||||
write_file File.join(@tempdir, plugin_path) do |io|
|
||||
io.write <<-PLUGIN
|
||||
#{self.class}.plugin_loaded = true
|
||||
Gem.post_install do
|
||||
#{self.class}.post_install_is_called = true
|
||||
end
|
||||
PLUGIN
|
||||
end
|
||||
spec.files += [plugin_path]
|
||||
plugin_path = File.join(spec.gem_dir, plugin_path)
|
||||
end
|
||||
build_rake_in do
|
||||
installer.install
|
||||
end
|
||||
assert self.class.plugin_loaded, "plugin is not loaded"
|
||||
assert self.class.post_install_is_called,
|
||||
"post install hook registered by plugin is not called"
|
||||
|
||||
self.class.plugin_loaded = false
|
||||
$LOADED_FEATURES.delete(plugin_path)
|
||||
installer_new = util_setup_installer do |spec_new|
|
||||
spec_new.version = spec_version.version.succ
|
||||
plugin_path = File.join("lib", "rubygems_plugin.rb")
|
||||
write_file File.join(@tempdir, plugin_path) do |io|
|
||||
io.write "#{self.class}.plugin_loaded = true"
|
||||
end
|
||||
spec_new.files += [plugin_path]
|
||||
end
|
||||
build_rake_in do
|
||||
installer_new.install
|
||||
end
|
||||
assert !self.class.plugin_loaded,
|
||||
"plugin is loaded even when old version is already loaded"
|
||||
end
|
||||
|
||||
def test_keeps_plugins_up_to_date
|
||||
# NOTE: version a-2 is already installed by setup hooks
|
||||
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
build_rake_in do
|
||||
|
|
|
@ -172,7 +172,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
|||
|
||||
def test_remove_plugins
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
@spec.files += %w[lib/rubygems_plugin.rb]
|
||||
|
@ -189,7 +189,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
|||
|
||||
def test_remove_plugins_with_install_dir
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
@spec.files += %w[lib/rubygems_plugin.rb]
|
||||
|
@ -207,7 +207,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
|||
|
||||
def test_regenerate_plugins_for
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
@spec.files += %w[lib/rubygems_plugin.rb]
|
||||
|
@ -634,7 +634,7 @@ create_makefile '#{@spec.name}'
|
|||
|
||||
def test_uninstall_keeps_plugins_up_to_date
|
||||
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
||||
io.write "puts __FILE__"
|
||||
io.write "# do nothing"
|
||||
end
|
||||
|
||||
plugin_path = File.join Gem.plugindir, "a_plugin.rb"
|
||||
|
|
|
@ -5,30 +5,30 @@ GEM
|
|||
hpricot (0.8.6)
|
||||
hpricot (0.8.6-java)
|
||||
mustache (1.1.1)
|
||||
parallel (1.22.1)
|
||||
parallel (1.23.0)
|
||||
parallel_tests (2.32.0)
|
||||
parallel
|
||||
power_assert (2.0.2)
|
||||
power_assert (2.0.3)
|
||||
rake (13.0.6)
|
||||
rb_sys (0.9.63)
|
||||
rb_sys (0.9.78)
|
||||
rdiscount (2.2.7)
|
||||
ronn (0.7.3)
|
||||
hpricot (>= 0.8.2)
|
||||
mustache (>= 0.7.0)
|
||||
rdiscount (>= 1.5.8)
|
||||
rspec-core (3.12.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.1)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.0)
|
||||
test-unit (3.5.5)
|
||||
test-unit (3.5.9)
|
||||
power_assert
|
||||
uri (0.12.0)
|
||||
webrick (1.7.0)
|
||||
uri (0.12.1)
|
||||
webrick (1.8.1)
|
||||
|
||||
PLATFORMS
|
||||
java
|
||||
|
@ -54,4 +54,4 @@ DEPENDENCIES
|
|||
webrick (~> 1.6)
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.13
|
||||
2.4.14
|
||||
|
|
|
@ -21,12 +21,12 @@ GEM
|
|||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
rspec-mocks (~> 3.12.0)
|
||||
rspec-core (3.12.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.1)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.0)
|
||||
|
@ -70,4 +70,4 @@ DEPENDENCIES
|
|||
test-unit
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.13
|
||||
2.4.14
|
||||
|
|
|
@ -22,12 +22,12 @@ GEM
|
|||
rspec-core (~> 3.12.0)
|
||||
rspec-expectations (~> 3.12.0)
|
||||
rspec-mocks (~> 3.12.0)
|
||||
rspec-core (3.12.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.1)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.0)
|
||||
|
@ -78,4 +78,4 @@ DEPENDENCIES
|
|||
test-unit
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.13
|
||||
2.4.14
|
||||
|
|
|
@ -42,4 +42,4 @@ DEPENDENCIES
|
|||
webrick (= 1.7.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.13
|
||||
2.4.14
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue