diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-11-11 17:57:45 +0900 |
---|---|---|
committer | SHIBATA Hiroshi <hsbt@ruby-lang.org> | 2019-11-11 18:56:25 +0900 |
commit | 7585bc31877d4f9725f8de51b4a2faf47acb6f34 (patch) | |
tree | adf61a7c20f7e54b595ebde05284b5e2862f552c /spec/bundler/support | |
parent | fd69f82675bf93a848e5aa58d117bf8bbf604188 (diff) |
Merge Bundler 2.1.0.pre.3
Features:
- Add caller information to some deprecation messages to make them easier to fix [#7361](https://github.com/bundler/bundler/pull/7361)
- Reconcile `bundle cache` vs `bundle package` everywhere. Now in docs, CLI help and everywhere else `bundle cache` is the preferred version and `bundle package` remains as an alias [#7389](https://github.com/bundler/bundler/pull/7389)
- Display some basic `bundler` documentation together with ruby's RDoc based documentation [#7394](https://github.com/bundler/bundler/pull/7394)
Bugfixes:
- Fix typos deprecation message and upgrading docs [#7374](https://github.com/bundler/bundler/pull/7374)
- Deprecation warnings about `taint` usage on ruby 2.7 [#7385](https://github.com/bundler/bundler/pull/7385)
- Fix `--help` flag not correctly delegating to `man` when used with command aliases [#7388](https://github.com/bundler/bundler/pull/7388)
- `bundle add` should cache newly added gems if an application cache exists [#7393](https://github.com/bundler/bundler/pull/7393)
- Stop using an insecure folder as a "fallback home" when user home is not defined [#7416](https://github.com/bundler/bundler/pull/7416)
- Fix `bundler/inline` warning about `Bundler.root` redefinition [#7417](https://github.com/bundler/bundler/pull/7417)
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2668
Diffstat (limited to 'spec/bundler/support')
49 files changed, 267 insertions, 105 deletions
diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb index 4f01690ae4..89362c4dbc 100644 --- a/spec/bundler/support/artifice/compact_index.rb +++ b/spec/bundler/support/artifice/compact_index.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" $LOAD_PATH.unshift Dir[base_system_gems.join("gems/compact_index*/lib")].first.to_s require "compact_index" diff --git a/spec/bundler/support/artifice/compact_index_api_missing.rb b/spec/bundler/support/artifice/compact_index_api_missing.rb index 94e6b73000..fdd342bc08 100644 --- a/spec/bundler/support/artifice/compact_index_api_missing.rb +++ b/spec/bundler/support/artifice/compact_index_api_missing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_basic_authentication.rb b/spec/bundler/support/artifice/compact_index_basic_authentication.rb index 97aa6cbd84..775f1a3977 100644 --- a/spec/bundler/support/artifice/compact_index_basic_authentication.rb +++ b/spec/bundler/support/artifice/compact_index_basic_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb b/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb index 62feb9f164..1abe64236c 100644 --- a/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb +++ b/spec/bundler/support/artifice/compact_index_checksum_mismatch.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_concurrent_download.rb b/spec/bundler/support/artifice/compact_index_concurrent_download.rb index 972ecb88b7..7f989a3f37 100644 --- a/spec/bundler/support/artifice/compact_index_concurrent_download.rb +++ b/spec/bundler/support/artifice/compact_index_concurrent_download.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_creds_diff_host.rb b/spec/bundler/support/artifice/compact_index_creds_diff_host.rb index 0d349bcc1e..6c3442e14b 100644 --- a/spec/bundler/support/artifice/compact_index_creds_diff_host.rb +++ b/spec/bundler/support/artifice/compact_index_creds_diff_host.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_extra.rb b/spec/bundler/support/artifice/compact_index_extra.rb index 84d1859235..3a09afd06f 100644 --- a/spec/bundler/support/artifice/compact_index_extra.rb +++ b/spec/bundler/support/artifice/compact_index_extra.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_extra_api.rb b/spec/bundler/support/artifice/compact_index_extra_api.rb index 903aa900fb..3c716763c0 100644 --- a/spec/bundler/support/artifice/compact_index_extra_api.rb +++ b/spec/bundler/support/artifice/compact_index_extra_api.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb index e72040f604..6bd24ddbb4 100644 --- a/spec/bundler/support/artifice/compact_index_extra_api_missing.rb +++ b/spec/bundler/support/artifice/compact_index_extra_api_missing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index_extra_api", __FILE__) +require_relative "compact_index_extra_api" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_extra_missing.rb b/spec/bundler/support/artifice/compact_index_extra_missing.rb index 67a9d23691..4758b785ac 100644 --- a/spec/bundler/support/artifice/compact_index_extra_missing.rb +++ b/spec/bundler/support/artifice/compact_index_extra_missing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index_extra", __FILE__) +require_relative "compact_index_extra" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_forbidden.rb b/spec/bundler/support/artifice/compact_index_forbidden.rb index 0a4dfdb2e8..3eebe0fbd8 100644 --- a/spec/bundler/support/artifice/compact_index_forbidden.rb +++ b/spec/bundler/support/artifice/compact_index_forbidden.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_host_redirect.rb b/spec/bundler/support/artifice/compact_index_host_redirect.rb index ab371117de..304c897d68 100644 --- a/spec/bundler/support/artifice/compact_index_host_redirect.rb +++ b/spec/bundler/support/artifice/compact_index_host_redirect.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_no_gem.rb b/spec/bundler/support/artifice/compact_index_no_gem.rb index 01c5be1b3d..0a4be08a46 100644 --- a/spec/bundler/support/artifice/compact_index_no_gem.rb +++ b/spec/bundler/support/artifice/compact_index_no_gem.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_partial_update.rb b/spec/bundler/support/artifice/compact_index_partial_update.rb index eaedff5105..6e7c05d423 100644 --- a/spec/bundler/support/artifice/compact_index_partial_update.rb +++ b/spec/bundler/support/artifice/compact_index_partial_update.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb b/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb index 487be4771a..788f9d6f99 100644 --- a/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb +++ b/spec/bundler/support/artifice/compact_index_range_not_satisfiable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_rate_limited.rb b/spec/bundler/support/artifice/compact_index_rate_limited.rb index d8f4fc941c..ba17476045 100644 --- a/spec/bundler/support/artifice/compact_index_rate_limited.rb +++ b/spec/bundler/support/artifice/compact_index_rate_limited.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_redirects.rb b/spec/bundler/support/artifice/compact_index_redirects.rb index e83451b5b6..99adc797bf 100644 --- a/spec/bundler/support/artifice/compact_index_redirects.rb +++ b/spec/bundler/support/artifice/compact_index_redirects.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb b/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb index abbf3258e7..7d427b5382 100644 --- a/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb +++ b/spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb b/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb index 7e1d3686e2..036fac70b3 100644 --- a/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb +++ b/spec/bundler/support/artifice/compact_index_wrong_dependencies.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb b/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb index db4d8e3974..8add32b88f 100644 --- a/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb +++ b/spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../compact_index", __FILE__) +require_relative "compact_index" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb b/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb index 12a6fa153f..c341c3993f 100644 --- a/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb +++ b/spec/bundler/support/artifice/endopint_marshal_fail_basic_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint_marshal_fail", __FILE__) +require_relative "endpoint_marshal_fail" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb index 966681f8d8..bf26c56503 100644 --- a/spec/bundler/support/artifice/endpoint.rb +++ b/spec/bundler/support/artifice/endpoint.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require File.expand_path("../../path.rb", __FILE__) -require Spec::Path.root.join("lib/bundler/deprecate") +require_relative "../path" +require Spec::Path.lib_dir.join("bundler/deprecate") include Spec::Path $LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s)) @@ -44,7 +44,7 @@ class Endpoint < Sinatra::Base def dependencies_for(gem_names, gem_repo = GEM_REPO) return [] if gem_names.nil? || gem_names.empty? - require "#{Spec::Path.lib}/bundler" + require "#{Spec::Path.lib_dir}/bundler" Bundler::Deprecate.skip_during do all_specs = %w[specs.4.8 prerelease_specs.4.8].map do |filename| Marshal.load(File.open(gem_repo.join(filename)).read) diff --git a/spec/bundler/support/artifice/endpoint_500.rb b/spec/bundler/support/artifice/endpoint_500.rb index ad51d58e67..f98e7e3bc2 100644 --- a/spec/bundler/support/artifice/endpoint_500.rb +++ b/spec/bundler/support/artifice/endpoint_500.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../../path.rb", __FILE__) +require_relative "../path" include Spec::Path $LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s)) diff --git a/spec/bundler/support/artifice/endpoint_api_forbidden.rb b/spec/bundler/support/artifice/endpoint_api_forbidden.rb index bb89747adc..edc2463424 100644 --- a/spec/bundler/support/artifice/endpoint_api_forbidden.rb +++ b/spec/bundler/support/artifice/endpoint_api_forbidden.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb index 2ada0dc553..8dafde7362 100644 --- a/spec/bundler/support/artifice/endpoint_api_missing.rb +++ b/spec/bundler/support/artifice/endpoint_api_missing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_basic_authentication.rb b/spec/bundler/support/artifice/endpoint_basic_authentication.rb index 223671bc29..ff3d1493d6 100644 --- a/spec/bundler/support/artifice/endpoint_basic_authentication.rb +++ b/spec/bundler/support/artifice/endpoint_basic_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_creds_diff_host.rb b/spec/bundler/support/artifice/endpoint_creds_diff_host.rb index 925954b12d..f20ef74ac6 100644 --- a/spec/bundler/support/artifice/endpoint_creds_diff_host.rb +++ b/spec/bundler/support/artifice/endpoint_creds_diff_host.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_extra.rb b/spec/bundler/support/artifice/endpoint_extra.rb index 422f65401b..31f6822161 100644 --- a/spec/bundler/support/artifice/endpoint_extra.rb +++ b/spec/bundler/support/artifice/endpoint_extra.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_extra_api.rb b/spec/bundler/support/artifice/endpoint_extra_api.rb index 62e2c2bb93..213b8e5895 100644 --- a/spec/bundler/support/artifice/endpoint_extra_api.rb +++ b/spec/bundler/support/artifice/endpoint_extra_api.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_extra_missing.rb b/spec/bundler/support/artifice/endpoint_extra_missing.rb index 038a12610a..ee129025ff 100644 --- a/spec/bundler/support/artifice/endpoint_extra_missing.rb +++ b/spec/bundler/support/artifice/endpoint_extra_missing.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint_extra", __FILE__) +require_relative "endpoint_extra" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_fallback.rb b/spec/bundler/support/artifice/endpoint_fallback.rb index 554c08f0a2..08edf232e3 100644 --- a/spec/bundler/support/artifice/endpoint_fallback.rb +++ b/spec/bundler/support/artifice/endpoint_fallback.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_host_redirect.rb b/spec/bundler/support/artifice/endpoint_host_redirect.rb index cda5664be2..338cbcad00 100644 --- a/spec/bundler/support/artifice/endpoint_host_redirect.rb +++ b/spec/bundler/support/artifice/endpoint_host_redirect.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_marshal_fail.rb b/spec/bundler/support/artifice/endpoint_marshal_fail.rb index 2a5dcdc2fd..22c13e3e17 100644 --- a/spec/bundler/support/artifice/endpoint_marshal_fail.rb +++ b/spec/bundler/support/artifice/endpoint_marshal_fail.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint_fallback", __FILE__) +require_relative "endpoint_fallback" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_mirror_source.rb b/spec/bundler/support/artifice/endpoint_mirror_source.rb index 64452f198d..318866e420 100644 --- a/spec/bundler/support/artifice/endpoint_mirror_source.rb +++ b/spec/bundler/support/artifice/endpoint_mirror_source.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" class EndpointMirrorSource < Endpoint get "/gems/:id" do diff --git a/spec/bundler/support/artifice/endpoint_redirect.rb b/spec/bundler/support/artifice/endpoint_redirect.rb index ebf01458ba..ee97fccf64 100644 --- a/spec/bundler/support/artifice/endpoint_redirect.rb +++ b/spec/bundler/support/artifice/endpoint_redirect.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb b/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb index 905a519f3f..4d4da08770 100644 --- a/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb +++ b/spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint", __FILE__) +require_relative "endpoint" Artifice.deactivate diff --git a/spec/bundler/support/artifice/endpoint_timeout.rb b/spec/bundler/support/artifice/endpoint_timeout.rb index 3f60471c90..c118da1893 100644 --- a/spec/bundler/support/artifice/endpoint_timeout.rb +++ b/spec/bundler/support/artifice/endpoint_timeout.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../endpoint_fallback", __FILE__) +require_relative "endpoint_fallback" Artifice.deactivate diff --git a/spec/bundler/support/artifice/vcr.rb b/spec/bundler/support/artifice/vcr.rb index 1e3809ff62..a46f8e9391 100644 --- a/spec/bundler/support/artifice/vcr.rb +++ b/spec/bundler/support/artifice/vcr.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require "net/http" +require_relative "../path" -CASSETTE_PATH = File.expand_path("../vcr_cassettes", __FILE__) +CASSETTE_PATH = "#{Spec::Path.spec_dir}/support/artifice/vcr_cassettes" CASSETTE_NAME = ENV.fetch("BUNDLER_SPEC_VCR_CASSETTE_NAME") { "realworld" } class BundlerVCRHTTP < Net::HTTP diff --git a/spec/bundler/support/artifice/windows.rb b/spec/bundler/support/artifice/windows.rb index 0630798df0..ce7455b86c 100644 --- a/spec/bundler/support/artifice/windows.rb +++ b/spec/bundler/support/artifice/windows.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require File.expand_path("../../path.rb", __FILE__) +require_relative "../path" include Spec::Path $LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,mustermann,rack,tilt,sinatra}-*/lib")].map(&:to_s)) diff --git a/spec/bundler/support/command_execution.rb b/spec/bundler/support/command_execution.rb index cec531d6c3..b3c289979f 100644 --- a/spec/bundler/support/command_execution.rb +++ b/spec/bundler/support/command_execution.rb @@ -1,12 +1,7 @@ # frozen_string_literal: true -require "support/helpers" -require "support/path" - module Spec CommandExecution = Struct.new(:command, :working_directory, :exitstatus, :stdout, :stderr) do - include RSpec::Matchers::Composable - def to_s c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) } c = c.reduce("") do |acc, elem| diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb new file mode 100644 index 0000000000..4ce6648cdc --- /dev/null +++ b/spec/bundler/support/filters.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require_relative "sudo" + +class RequirementChecker < Proc + def self.against(present) + provided = Gem::Version.new(present) + + new do |required| + !Gem::Requirement.new(required).satisfied_by?(provided) + end.tap do |checker| + checker.provided = provided + end + end + + attr_accessor :provided + + def inspect + "\"!= #{provided}\"" + end +end + +RSpec.configure do |config| + if ENV["BUNDLER_SUDO_TESTS"] && Spec::Sudo.present? + config.filter_run :sudo => true + else + config.filter_run_excluding :sudo => true + end + + if ENV["BUNDLER_REALWORLD_TESTS"] + config.filter_run :realworld => true + else + config.filter_run_excluding :realworld => true + end + + git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version + + config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION) + config.filter_run_excluding :git => RequirementChecker.against(git_version) + config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0]) + config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil? + config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil? + + config.filter_run_when_matching :focus unless ENV["CI"] +end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 0c05789946..8bf76bba89 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -2,6 +2,9 @@ require "open3" +require_relative "command_execution" +require_relative "the_bundle" + module Spec module Helpers def reset! @@ -16,8 +19,6 @@ module Spec FileUtils.mkdir_p(home) FileUtils.mkdir_p(tmpdir) Bundler.reset! - Bundler.ui = nil - Bundler.ui # force it to initialize end def self.bang(method) @@ -77,7 +78,7 @@ module Spec def run(cmd, *args) opts = args.last.is_a?(Hash) ? args.pop : {} groups = args.map(&:inspect).join(", ") - setup = "require '#{lib}/bundler' ; Bundler.setup(#{groups})\n" + setup = "require '#{lib_dir}/bundler' ; Bundler.ui.silence { Bundler.setup(#{groups}) }\n" ruby(setup + cmd, opts) end bang :run @@ -95,10 +96,6 @@ module Spec run(cmd, *args) end - def spec - spec_dir.to_s - end - def bundle(cmd, options = {}) with_sudo = options.delete(:sudo) sudo = with_sudo == :preserve_env ? "sudo -E" : "sudo" if with_sudo @@ -113,6 +110,7 @@ module Spec env["PATH"].gsub!("#{Path.root}/exe", "") if env["PATH"] && system_bundler requires = options.delete(:requires) || [] + requires << "support/rubygems" requires << "support/hax" artifice = options.delete(:artifice) do @@ -123,14 +121,14 @@ module Spec end end if artifice - requires << File.expand_path("../artifice/#{artifice}", __FILE__) + requires << "support/artifice/#{artifice}" end requires_str = requires.map {|r| "-r#{r}" }.join(" ") load_path = [] - load_path << lib unless system_bundler - load_path << spec + load_path << lib_dir unless system_bundler + load_path << spec_dir load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}" args = options.map do |k, v| @@ -146,7 +144,7 @@ module Spec end end.join - cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}" + cmd = "#{sudo} #{Gem.ruby} --disable-gems #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}" sys_exec(cmd, env) {|i, o, thr| yield i, o, thr if block_given? } end bang :bundle @@ -174,10 +172,10 @@ module Spec end def ruby(ruby, options = {}) - env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join + env = options.delete(:env) || {} ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" } - lib_option = options[:no_lib] ? "" : " -I#{lib}" - sys_exec(%(#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}")) + lib_option = options[:no_lib] ? "" : " -I#{lib_dir}" + sys_exec(%(#{Gem.ruby}#{lib_option} -e "#{ruby}"), env) end bang :ruby @@ -193,7 +191,7 @@ module Spec def gembin(cmd) old = ENV["RUBYOPT"] - ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{lib}" + ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{lib_dir}" cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/") sys_exec(cmd.to_s) ensure @@ -513,10 +511,6 @@ module Spec Dir.chdir(path) { `git rev-parse HEAD`.strip } end - def capture_output - capture(:stdout) - end - def with_read_only(pattern) chmod = lambda do |dirmode, filemode| lambda do |f| diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb index b0493801e8..69d3be4a3d 100644 --- a/spec/bundler/support/matchers.rb +++ b/spec/bundler/support/matchers.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true require "forwardable" -require "support/the_bundle" +require_relative "the_bundle" + module Spec module Matchers extend RSpec::Matchers @@ -170,7 +171,7 @@ module Spec end R rescue StandardError => e - next "checking for #{name} failed:\n#{e}" + next "checking for #{name} failed:\n#{e}\n#{e.backtrace.join("\n")}" end next if out == "WIN" next "expected #{name} to not be installed, but it was" if version.nil? diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index db28454792..b957e24abe 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -22,7 +22,7 @@ module Spec end def gem_bin - @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} -S gem --backtrace" + @gem_bin ||= ruby_core? ? ENV["GEM_COMMAND"] : "#{Gem.ruby} --disable-gems -r#{spec_dir}/support/rubygems -S gem --backtrace" end def spec_dir @@ -131,7 +131,7 @@ module Spec tmp("libs", *args) end - def lib + def lib_dir root.join("lib") end diff --git a/spec/bundler/support/requirement_checker.rb b/spec/bundler/support/requirement_checker.rb deleted file mode 100644 index e6bd0eb50d..0000000000 --- a/spec/bundler/support/requirement_checker.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class RequirementChecker < Proc - def self.against(present) - provided = Gem::Version.new(present) - - new do |required| - !Gem::Requirement.new(required).satisfied_by?(provided) - end.tap do |checker| - checker.provided = provided - end - end - - attr_accessor :provided - - def inspect - "\"!= #{provided}\"" - end -end diff --git a/spec/bundler/support/rubygems.rb b/spec/bundler/support/rubygems.rb new file mode 100644 index 0000000000..e60f9a928e --- /dev/null +++ b/spec/bundler/support/rubygems.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require_relative "rubygems_version_manager" + +RubygemsVersionManager.new(ENV["RGV"]).switch + +require "rubygems" diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index faa474a917..1093362d81 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "rubygems/user_interaction" require_relative "path" require "fileutils" @@ -29,7 +28,9 @@ module Spec "ruby-graphviz" => ">= 0.a", }.freeze - def self.dev_setup + extend self + + def dev_setup deps = DEV_DEPS # JRuby can't build ronn, so we skip that @@ -38,22 +39,17 @@ module Spec install_gems(deps) end - def self.gem_load(gem_name, bin_container) - gem_activate(gem_name) - load Gem.bin_path(gem_name, bin_container) + def gem_load(gem_name, bin_container) + require_relative "rubygems" + gem_load_and_activate(gem_name, bin_container) end - def self.gem_activate(gem_name) - gem_requirement = DEV_DEPS[gem_name] - gem gem_name, gem_requirement - end - - def self.gem_require(gem_name) + def gem_require(gem_name) gem_activate(gem_name) require gem_name end - def self.setup + def setup Gem.clear_paths ENV["BUNDLE_PATH"] = nil @@ -71,20 +67,37 @@ module Spec manifest_path.open("w") {|f| f << manifest.join } end + FileUtils.mkdir_p(Path.home) + FileUtils.mkdir_p(Path.tmpdir) + ENV["HOME"] = Path.home.to_s ENV["TMPDIR"] = Path.tmpdir.to_s + require "rubygems/user_interaction" Gem::DefaultUserInteraction.ui = Gem::SilentUI.new end - def self.install_gems(gems) + private + + def gem_load_and_activate(gem_name, bin_container) + gem_activate(gem_name) + load Gem.bin_path(gem_name, bin_container) + rescue Gem::LoadError => e + abort "We couln't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`" + end + + def gem_activate(gem_name) + gem_requirement = DEV_DEPS[gem_name] + gem gem_name, gem_requirement + end + + def install_gems(gems) reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? } no_reqs.map!(&:first) reqs.map! {|name, req| "'#{name}:#{req}'" } deps = reqs.concat(no_reqs).join(" ") gem = Path.gem_bin cmd = "#{gem} install #{deps} --no-document --conservative" - puts cmd system(cmd) || raise("Installing gems #{deps} for the tests to use failed!") end end diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb new file mode 100644 index 0000000000..31f7cc4b08 --- /dev/null +++ b/spec/bundler/support/rubygems_version_manager.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +require "pathname" +require_relative "helpers" +require_relative "path" + +class RubygemsVersionManager + include Spec::Helpers + include Spec::Path + + def initialize(env_version) + @env_version = env_version + end + + def switch + return if use_system? + + unrequire_rubygems_if_needed + + switch_local_copy_if_needed + + prepare_environment + end + +private + + def use_system? + @env_version.nil? + end + + def unrequire_rubygems_if_needed + return unless rubygems_unrequire_needed? + + require "rbconfig" + + ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"]) + ruby << RbConfig::CONFIG["EXEEXT"] + + cmd = [ruby, $0, *ARGV].compact + cmd[1, 0] = "--disable-gems" + + exec(ENV, *cmd) + end + + def switch_local_copy_if_needed + return unless local_copy_switch_needed? + + Dir.chdir(local_copy_path) do + sys_exec!("git remote update") + sys_exec!("git checkout #{target_tag_version} --quiet") + end + end + + def prepare_environment + $:.unshift File.expand_path("lib", local_copy_path) + end + + def rubygems_unrequire_needed? + defined?(Gem) && Gem::VERSION != target_gem_version + end + + def local_copy_switch_needed? + !env_version_is_path? && target_gem_version != local_copy_version + end + + def target_gem_version + @target_gem_version ||= resolve_target_gem_version + end + + def target_tag_version + @target_tag_version ||= resolve_target_tag_version + end + + def local_copy_version + gemspec_contents = File.read(local_copy_path.join("lib/rubygems.rb")) + version_regexp = /VERSION = ["'](.*)["']/ + + version_regexp.match(gemspec_contents)[1] + end + + def local_copy_path + @local_copy_path ||= resolve_local_copy_path + end + + def resolve_local_copy_path + return expanded_env_version if env_version_is_path? + + rubygems_path = root.join("tmp/rubygems") + + unless rubygems_path.directory? + rubygems_path.parent.mkpath + sys_exec!("git clone https://github.com/rubygems/rubygems.git #{rubygems_path}") + end + + rubygems_path + end + + def env_version_is_path? + expanded_env_version.directory? + end + + def expanded_env_version + @expanded_env_version ||= Pathname.new(@env_version).expand_path(root) + end + + def resolve_target_tag_version + return "v#{@env_version}" if @env_version.match(/^\d/) + + return "master" if @env_version == master_gem_version + + @env_version + end + + def resolve_target_gem_version + return local_copy_version if env_version_is_path? + + return @env_version[1..-1] if @env_version.match(/^v/) + + return master_gem_version if @env_version == "master" + + @env_version + end + + def master_gem_version + "3.1.0.pre1" + end +end diff --git a/spec/bundler/support/the_bundle.rb b/spec/bundler/support/the_bundle.rb index c994eaae78..f252a4515b 100644 --- a/spec/bundler/support/the_bundle.rb +++ b/spec/bundler/support/the_bundle.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require "support/helpers" -require "support/path" +require_relative "path" module Spec class TheBundle - include Spec::Helpers include Spec::Path attr_accessor :bundle_dir |