From 15ebada13e8c9feeba784d16e4186616eb68747f Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Fri, 28 Dec 2018 00:29:03 -0500 Subject: [PATCH 1/8] Test against Ruby 2.6 and RubyGems 3 --- .travis.yml | 21 ++++++++++++++++----- Rakefile | 2 +- lib/bundler/current_ruby.rb | 1 + man/gemfile.5.ronn | 8 ++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 846ff33746a..02c60d693c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,8 @@ addons: secure: "TrzIv116JLGUxm6PAUskCYrv8KTDguncKROVwbnjVPKTGDAgoDderd8JUdDEXrKoZ9qGLD2TPYKExt9/QDl71E+qHdWnVqWv4HKCUk2P9z/VLKzHuggOUBkCXiJUhjywUieCJhI3N92bfq2EjSBbu2/OFHqWOjLQ+QCooTEBjv8=" rvm: - - 2.5.2 + - 2.6.0 + - 2.5.3 - 2.4.5 - 2.3.8 @@ -41,17 +42,24 @@ env: # We need to know if changes to rubygems will break bundler on release - RGV=master # Test the latest rubygems release with all of our supported rubies - - RGV=v2.7.7 + - RGV=v3.0.1 jobs: include: - - rvm: 2.5 + - rvm: 2.6.0 script: rake rubocop stage: linting + # Ruby 2.5, Rubygems 2.7 and up + - rvm: 2.5.3 + env: RGV=v2.7.7 + stage: test # Ruby 2.4, Rubygems 2.6 and up - - rvm: 2.4.2 + - rvm: 2.4.5 env: RGV=v2.6.14 stage: test + - rvm: 2.4.5 + env: RGV=v2.7.7 + stage: test # Ruby 2.3, Rubygems 2.5 and up - rvm: 2.3.7 env: RGV=v2.5.2 @@ -59,12 +67,15 @@ jobs: - rvm: 2.3.7 env: RGV=v2.6.14 stage: test + - rvm: 2.3.7 + env: RGV=v2.7.7 + stage: test # Ruby-head (we want to know how we're doing, but not fail the build) - rvm: ruby-head env: RGV=master stage: test # 1.x mode (we want to keep stuff passing in 1.x mode for now) - - rvm: 2.5.1 + - rvm: 2.6.0 env: RGV=v2.7.7 BUNDLER_SPEC_SUB_VERSION=1.98 stage: test - rvm: 1.8.7 diff --git a/Rakefile b/Rakefile index 6a5ce7d3275..746d110f864 100644 --- a/Rakefile +++ b/Rakefile @@ -141,7 +141,7 @@ begin rubyopt = ENV["RUBYOPT"] # When editing this list, also edit .travis.yml! branches = %w[master] - releases = %w[v2.5.2 v2.6.14 v2.7.7] + releases = %w[v2.5.2 v2.6.14 v2.7.7 v3.0.1] (branches + releases).each do |rg| desc "Run specs with RubyGems #{rg}" RSpec::Core::RakeTask.new(rg) do |t| diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index d5efaad6c52..ae5fae841e6 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -19,6 +19,7 @@ class CurrentRuby 2.4 2.5 2.6 + 2.7 ].freeze KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze diff --git a/man/gemfile.5.ronn b/man/gemfile.5.ronn index f4772f6d8d6..c941463edcf 100644 --- a/man/gemfile.5.ronn +++ b/man/gemfile.5.ronn @@ -216,13 +216,13 @@ used on platforms with Ruby 2.3, use: The full list of platforms and supported versions includes: * `ruby`: - 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 + 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 * `mri`: - 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 + 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 * `mingw`: - 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 + 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 * `x64_mingw`: - 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 + 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 As with groups, you can specify one or more platforms: From dcfc2750a09534d82494e0451cefe6382d2cbc98 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Fri, 28 Dec 2018 01:29:01 -0500 Subject: [PATCH 2/8] Fix specs that are broken in ruby 2.6 --- bundler.gemspec | 4 +--- lib/bundler/spec_set.rb | 25 ++++++++++++++++++++----- spec/runtime/setup_spec.rb | 4 +++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index c004de09652..be87e4003f0 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -8,8 +8,6 @@ rescue LoadError require File.expand_path("../bundler/version", __FILE__) end -require "shellwords" - Gem::Specification.new do |s| s.name = "bundler" s.version = Bundler::VERSION @@ -49,7 +47,7 @@ Gem::Specification.new do |s| s.add_development_dependency "ronn", "~> 0.7.3" s.add_development_dependency "rspec", "~> 3.6" - s.files = `git -C #{Shellwords.escape File.dirname(__FILE__)} ls-files -z`.split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + s.files = IO.popen(["git", "-C", File.dirname(__FILE__), "ls-files", "-z"], &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } # we don't check in man pages, but we need to ship them because # we use them to generate the long-form help for each command. diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index e6c30603f08..2c5d9e6580f 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -1,18 +1,13 @@ # frozen_string_literal: true require "tsort" -require "forwardable" require "set" module Bundler class SpecSet - extend Forwardable include Enumerable include TSort - def_delegators :@specs, :<<, :length, :add, :remove, :size, :empty? - def_delegators :sorted, :each - def initialize(specs) @specs = specs end @@ -132,6 +127,26 @@ def what_required(spec) what_required(req) << spec end + def <<(spec) + @specs << spec + end + + def length + @specs.length + end + + def size + @specs.size + end + + def empty? + @specs.empty? + end + + def each(&b) + sorted.each(&b) + end + private def sorted diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 7ea7d5ea0b3..941c3d34e7f 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -882,7 +882,9 @@ def clean_load_path(lp) end end - it "should successfully require 'bundler/setup'", :ruby_repo do + # Can't make this pass on 2.6 since the ruby standard library has the same $LOAD_PATH + # entry as bundler (since it's a default gem) + it "should successfully require 'bundler/setup'", :ruby_repo, :ruby => "< 2.6" do install_gemfile "" ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true From 21ac802b8c54718687a8682c396fc31e5a215ebc Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Fri, 28 Dec 2018 21:44:25 +1100 Subject: [PATCH 3/8] set `bundle` spec helper to load the system bundler binstub directly instead of depending on the $PATH --- spec/support/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 98a4096216d..a6b9cfdc353 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -104,7 +104,7 @@ def bundle(cmd, options = {}) bundle_bin = options.delete("bundle_bin") || bindir.join("bundle") if system_bundler = options.delete(:system_bundler) - bundle_bin = "-S bundle" + bundle_bin = system_gem_path.join("bin/bundler") end env = options.delete(:env) || {} From e63e844bc7444c6a489fcde0dc7011c6c4807edd Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Fri, 28 Dec 2018 22:22:14 +1100 Subject: [PATCH 4/8] make system_bundle_bin_path helper and resolve failing tests for ruby < 2.6 --- spec/commands/exec_spec.rb | 3 ++- spec/support/helpers.rb | 2 +- spec/support/path.rb | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index fdf60cefe71..7503b9db5f0 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -800,10 +800,11 @@ def bin_path(a,b,c) it "overrides disable_shared_gems so bundler can be found" do skip "bundler 1.16.x is not support with Ruby 2.6 on Travis CI" if RUBY_VERSION >= "2.6" + system_gems :bundler file = bundled_app("file_that_bundle_execs.rb") create_file(file, <<-RB) #!#{Gem.ruby} - puts `bundle exec echo foo` + puts `#{system_bundle_bin_path} exec echo foo` RB file.chmod(0o777) bundle! "exec #{file}", :system_bundler => true diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index a6b9cfdc353..9126256f8e9 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -104,7 +104,7 @@ def bundle(cmd, options = {}) bundle_bin = options.delete("bundle_bin") || bindir.join("bundle") if system_bundler = options.delete(:system_bundler) - bundle_bin = system_gem_path.join("bin/bundler") + bundle_bin = system_bundle_bin_path end env = options.delete(:env) || {} diff --git a/spec/support/path.rb b/spec/support/path.rb index c28414e0833..f85fbf330f2 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -90,6 +90,10 @@ def system_gem_path(*path) tmp("gems/system", *path) end + def system_bundle_bin_path + system_gem_path("bin/bundle") + end + def lib_path(*args) tmp("libs", *args) end From c77d49660c489d1a25676622e32410b0b284d6fe Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Fri, 28 Dec 2018 22:33:32 +1100 Subject: [PATCH 5/8] fix usuage of IO.popen on Ruby 1.8 --- bundler.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler.gemspec b/bundler.gemspec index be87e4003f0..634340e6f31 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -47,7 +47,7 @@ Gem::Specification.new do |s| s.add_development_dependency "ronn", "~> 0.7.3" s.add_development_dependency "rspec", "~> 3.6" - s.files = IO.popen(["git", "-C", File.dirname(__FILE__), "ls-files", "-z"], &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + s.files = IO.popen("git -C #{File.dirname(__FILE__)} ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } # we don't check in man pages, but we need to ship them because # we use them to generate the long-form help for each command. From 3472aa9750252ed83dc32c348c2bd3082dd00d4e Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Sat, 29 Dec 2018 17:11:42 +1100 Subject: [PATCH 6/8] embed Shellwords.escape into bundler gemspec --- bundler.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundler.gemspec b/bundler.gemspec index 634340e6f31..12b1b59b985 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -47,7 +47,8 @@ Gem::Specification.new do |s| s.add_development_dependency "ronn", "~> 0.7.3" s.add_development_dependency "rspec", "~> 3.6" - s.files = IO.popen("git -C #{File.dirname(__FILE__)} ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } + base_dir = File.dirname(__FILE__).gsub(%r{([^A-Za-z0-9_\-.,:\/@\n])}, "\\\\\\1") + s.files = IO.popen("git -C #{base_dir} ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } # we don't check in man pages, but we need to ship them because # we use them to generate the long-form help for each command. From a2e9d1ba187d311927b56471bcbe70271b3c49f7 Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Sat, 29 Dec 2018 17:12:04 +1100 Subject: [PATCH 7/8] ignore RubyGems warnings about deprecated methods in version.rb --- spec/quality_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index e85d0bfa970..64590befdf3 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -260,7 +260,11 @@ def check_for_specific_pronouns(filename) end end - expect(last_command.stdboth.split("\n")).to be_well_formed + warnings = last_command.stdboth.split("\n") + # ignore warnings around deprecated Object#=~ method in RubyGems + warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} } + + expect(warnings).to be_well_formed end end end From 4937db20ef20823036d2a4e4be5b1ae6f0361755 Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Sat, 29 Dec 2018 18:07:27 +1100 Subject: [PATCH 8/8] fix breaking bundler 1 spec for ruby 2.6 with RG 2.7 --- spec/lock/lockfile_bundler_1_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index fcdf6ebf0d6..638b40f5f48 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -78,7 +78,7 @@ it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do version = "#{Bundler::VERSION.split(".").first}.0.0.0.a" - lockfile <<-L + lockfile normalize_uri_file(<<-L) GEM remote: file://localhost#{gem_repo1}/ specs: @@ -94,13 +94,13 @@ #{version} L - install_gemfile <<-G + install_gemfile normalize_uri_file(<<-G) source "file://localhost#{gem_repo1}" gem "rack" G - lockfile_should_be <<-G + lockfile_should_be normalize_uri_file(<<-G) GEM remote: file://localhost#{gem_repo1}/ specs: