From 6a7da1cc9a59cd7e1399f28b5398f1223b89c56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 18 Sep 2019 10:06:10 +0200 Subject: Replace `with_rubygems` script Instead, use a better rubygems version manager that makes sure that `ENV["RGV"]` usage is always applied, and its usage is centralized at a single place. This simplifies the rake task organization and makes it much simpler to run locally exactly what's run in CI. For example, since it doesn't rely on the `RGV` being deleted for subsequent subprocesses, it also running `bin/rake spec:travis` task locally which previously would lead to ``` rake aborted! RubyGems version is required on Travis! ``` It also reduces duplication making it so that we only need to change the `.travis.yml` file when updating tested rubies, and not the `Rakefile` as well. --- bin/parallel_rspec | 2 -- bin/rake | 2 -- bin/ronn | 2 -- bin/rspec | 2 -- bin/rubocop | 2 -- bin/with_rubygems | 45 --------------------------------------------- 6 files changed, 55 deletions(-) delete mode 100755 bin/with_rubygems (limited to 'bin') diff --git a/bin/parallel_rspec b/bin/parallel_rspec index 9783533198..c6fb33d583 100755 --- a/bin/parallel_rspec +++ b/bin/parallel_rspec @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] - require_relative "../spec/support/rubygems_ext" Spec::Rubygems.gem_load("parallel_tests", "parallel_rspec") diff --git a/bin/rake b/bin/rake index 2fb69d19f3..6a443ab2d9 100755 --- a/bin/rake +++ b/bin/rake @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] - require_relative "../spec/support/rubygems_ext" Spec::Rubygems.gem_load("rake", "rake") diff --git a/bin/ronn b/bin/ronn index e47fb518a4..d7084e307e 100755 --- a/bin/ronn +++ b/bin/ronn @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] - require_relative "../spec/support/rubygems_ext" Spec::Rubygems.gem_load("ronn", "ronn") diff --git a/bin/rspec b/bin/rspec index 4c139156f9..250b9cfb54 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] - require_relative "../spec/support/rubygems_ext" Spec::Rubygems.gem_load("rspec-core", "rspec") diff --git a/bin/rubocop b/bin/rubocop index 818aaf7a9d..3716bffe31 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,8 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] - require_relative "../spec/support/rubygems_ext" Spec::Rubygems.gem_load("rubocop", "rubocop") diff --git a/bin/with_rubygems b/bin/with_rubygems deleted file mode 100755 index 59365e40ce..0000000000 --- a/bin/with_rubygems +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require "pathname" -require_relative "../spec/support/helpers" - -class RubygemsVersionManager - include Spec::Helpers -end - -rubygems_version_manager = RubygemsVersionManager.new - -version = ENV.delete("RGV") -rubygems_path = Pathname.new(version).expand_path -unless rubygems_path.directory? - rubygems_path = Pathname.new("tmp/rubygems").expand_path - unless rubygems_path.directory? - rubygems_path.parent.mkpath - rubygems_version_manager.sys_exec!("git clone https://github.com/rubygems/rubygems.git #{rubygems_path}") - end - Dir.chdir(rubygems_path) do - rubygems_version_manager.sys_exec!("git remote update") - version = "v#{version}" if version =~ /\A\d/ - rubygems_version_manager.sys_exec!("git checkout #{version} --quiet") - end -end - -rubygems_lib = rubygems_path + "lib" -ENV["RUBYOPT"] = %(-I#{rubygems_lib} #{ENV["RUBYOPT"]}) - -if $0 != __FILE__ - ARGV.unshift($0) -elsif cmd = ARGV.first - possible_dirs = [ - Pathname.new(__FILE__) + "..", - Pathname.new(__FILE__) + "../../exe", - rubygems_path + "bin", - ] - cmd = possible_dirs.map do |dir| - dir.join(cmd).expand_path - end.find(&:file?) - ARGV[0] = cmd.to_s if cmd -end - -exec(*ARGV) -- cgit v1.2.1