1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge rubygems master 1e4eda741d732ca1bd7031aef0a16c7348adf7a5

This commit is contained in:
Hiroshi SHIBATA 2022-04-01 20:36:59 +09:00
parent 479ba9a44b
commit 678d58c850
Notes: git 2022-04-28 19:09:13 +09:00
40 changed files with 72 additions and 76 deletions

View file

@ -370,7 +370,7 @@ EOF
if env.key?("RUBYLIB") if env.key?("RUBYLIB")
rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR) rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
rubylib.delete(File.expand_path("..", __FILE__)) rubylib.delete(__dir__)
env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR) env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
end end

View file

@ -27,7 +27,7 @@ module Bundler
# If Bundler has been installed without its .git directory and without a # If Bundler has been installed without its .git directory and without a
# commit instance variable then we can't determine its commits SHA. # commit instance variable then we can't determine its commits SHA.
git_dir = File.join(File.expand_path("../../../..", __FILE__), ".git") git_dir = File.expand_path("../../../.git", __dir__)
if File.directory?(git_dir) if File.directory?(git_dir)
return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze } return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
end end

View file

@ -610,7 +610,7 @@ module Bundler
private :gem private :gem
def self.source_root def self.source_root
File.expand_path(File.join(File.dirname(__FILE__), "templates")) File.expand_path("templates", __dir__)
end end
desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true

View file

@ -47,7 +47,7 @@ module Bundler
def print_gem_path(spec) def print_gem_path(spec)
name = spec.name name = spec.name
if name == "bundler" if name == "bundler"
path = File.expand_path("../../../..", __FILE__) path = File.expand_path("../../..", __dir__)
else else
path = spec.full_gem_path path = spec.full_gem_path
if spec.deleted_gem? if spec.deleted_gem?

View file

@ -32,7 +32,7 @@ module Bundler
file << spec.to_gemfile file << spec.to_gemfile
end end
else else
FileUtils.cp(File.expand_path("../../templates/#{gemfile}", __FILE__), gemfile) FileUtils.cp(File.expand_path("../templates/#{gemfile}", __dir__), gemfile)
end end
puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}" puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"

View file

@ -18,7 +18,7 @@ module Bundler
if gem_name if gem_name
if gem_name == "bundler" if gem_name == "bundler"
path = File.expand_path("../../../..", __FILE__) path = File.expand_path("../../..", __dir__)
else else
spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match) spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
return unless spec return unless spec

View file

@ -119,7 +119,7 @@ module Bundler
relative_gemfile_path = relative_gemfile_path relative_gemfile_path = relative_gemfile_path
ruby_command = Thor::Util.ruby_command ruby_command = Thor::Util.ruby_command
ruby_command = ruby_command ruby_command = ruby_command
template_path = File.expand_path("../templates/Executable", __FILE__) template_path = File.expand_path("templates/Executable", __dir__)
if spec.name == "bundler" if spec.name == "bundler"
template_path += ".bundler" template_path += ".bundler"
spec.executables = %(bundle) spec.executables = %(bundle)
@ -172,7 +172,7 @@ module Bundler
end end
standalone_path = Bundler.root.join(path).relative_path_from(bin_path) standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
standalone_path = standalone_path standalone_path = standalone_path
template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__)) template = File.read(File.expand_path("templates/Executable.standalone", __dir__))
ruby_command = Thor::Util.ruby_command ruby_command = Thor::Util.ruby_command
ruby_command = ruby_command ruby_command = ruby_command

View file

@ -274,10 +274,10 @@ module Bundler
def set_bundle_variables def set_bundle_variables
# bundler exe & lib folders have same root folder, typical gem installation # bundler exe & lib folders have same root folder, typical gem installation
exe_file = File.expand_path("../../../exe/bundle", __FILE__) exe_file = File.expand_path("../../exe/bundle", __dir__)
# for Ruby core repository testing # for Ruby core repository testing
exe_file = File.expand_path("../../../libexec/bundle", __FILE__) unless File.exist?(exe_file) exe_file = File.expand_path("../../libexec/bundle", __dir__) unless File.exist?(exe_file)
# bundler is a default gem, exe path is separate # bundler is a default gem, exe path is separate
exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file) exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
@ -309,7 +309,7 @@ module Bundler
end end
def bundler_ruby_lib def bundler_ruby_lib
resolve_path File.expand_path("../..", __FILE__) File.expand_path("..", __dir__)
end end
def clean_load_path def clean_load_path

View file

@ -22,7 +22,7 @@ module Bundler
s.summary = "The best way to manage your application's dependencies" s.summary = "The best way to manage your application's dependencies"
s.executables = %w[bundle] s.executables = %w[bundle]
# can't point to the actual gemspec or else the require paths will be wrong # can't point to the actual gemspec or else the require paths will be wrong
s.loaded_from = File.expand_path("..", __FILE__) s.loaded_from = __dir__
end end
if local_spec = Bundler.rubygems.find_bundler(VERSION) if local_spec = Bundler.rubygems.find_bundler(VERSION)

View file

@ -8,11 +8,9 @@
# this file is here to facilitate running it. # this file is here to facilitate running it.
# #
require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path("../bundle", __FILE__) bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub) if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/

View file

@ -41,7 +41,7 @@ m = Module.new do
gemfile = ENV["BUNDLE_GEMFILE"] gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty? return gemfile if gemfile && !gemfile.empty?
File.expand_path("../<%= relative_gemfile_path %>", __FILE__) File.expand_path("<%= relative_gemfile_path %>", __dir__)
end end
def lockfile def lockfile

View file

@ -6,9 +6,7 @@
# this file is here to facilitate running it. # this file is here to facilitate running it.
# #
require "pathname" $:.unshift File.expand_path "<%= standalone_path %>", __dir__
path = Pathname.new(__FILE__)
$:.unshift File.expand_path "../<%= standalone_path %>", path.realpath
require "bundler/setup" require "bundler/setup"
load File.expand_path "../<%= executable_path %>", path.realpath load File.expand_path "<%= executable_path %>", __dir__

View file

@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released. # Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path(__dir__)) do spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f| `git ls-files -z`.split("\x0").reject do |f|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}) (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
end end

View file

@ -112,7 +112,7 @@ require_relative 'rubygems/errors'
# -The RubyGems Team # -The RubyGems Team
module Gem module Gem
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__) RUBYGEMS_DIR = __dir__
# Taint support is deprecated in Ruby 2.7. # Taint support is deprecated in Ruby 2.7.
# This allows switching ".untaint" to ".tap(&Gem::UNTAINT)", # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",

View file

@ -341,7 +341,7 @@ By default, this RubyGems will install gem as:
fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION
def fake_spec.full_gem_path def fake_spec.full_gem_path
File.expand_path '../../../..', __FILE__ File.expand_path '../../..', __dir__
end end
generate_ri = options[:document].include? 'ri' generate_ri = options[:document].include? 'ri'

View file

@ -39,7 +39,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
# workaround for https://github.com/oracle/truffleruby/issues/2115 # workaround for https://github.com/oracle/truffleruby/issues/2115
siteconf_path = RUBY_ENGINE == "truffleruby" ? siteconf.path.dup : siteconf.path siteconf_path = RUBY_ENGINE == "truffleruby" ? siteconf.path.dup : siteconf.path
require "shellwords" require "shellwords"
cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../../..", __FILE__) << cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) <<
"-r" << get_relative_path(siteconf_path, extension_dir) << File.basename(extension) "-r" << get_relative_path(siteconf_path, extension_dir) << File.basename(extension)
cmd.push(*args) cmd.push(*args)

View file

@ -39,7 +39,7 @@ class Gem::Request
def cert_files; @connection_pool.cert_files; end def cert_files; @connection_pool.cert_files; end
def self.get_cert_files def self.get_cert_files
pattern = File.expand_path("./ssl_certs/*/*.pem", File.dirname(__FILE__)) pattern = File.expand_path("./ssl_certs/*/*.pem", __dir__)
Dir.glob(pattern) Dir.glob(pattern)
end end

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
load File.expand_path("../bundle", __FILE__) load File.expand_path("bundle", __dir__)

View file

@ -798,7 +798,7 @@ RSpec.describe "bundle install with gem sources" do
it "includes the standalone path" do it "includes the standalone path" do
bundle "binstubs rack", :standalone => true bundle "binstubs rack", :standalone => true
standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
expect(standalone_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath) expect(standalone_line).to eq %($:.unshift File.expand_path "../bundle", __dir__)
end end
end end

View file

@ -1147,7 +1147,7 @@ RSpec.describe "bundle update --bundler" do
end end
it "updates the bundler version in the lockfile without re-resolving if the highest version is already installed" do it "updates the bundler version in the lockfile without re-resolving if the highest version is already installed" do
system_gems "bundler-2.3.3" system_gems "bundler-2.3.9"
build_repo4 do build_repo4 do
build_gem "rack", "1.0" build_gem "rack", "1.0"
@ -1157,7 +1157,7 @@ RSpec.describe "bundle update --bundler" do
source "#{file_uri_for(gem_repo4)}" source "#{file_uri_for(gem_repo4)}"
gem "rack" gem "rack"
G G
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9")
bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true
expect(out).to include("Using bundler #{Bundler::VERSION}") expect(out).to include("Using bundler #{Bundler::VERSION}")
@ -1182,7 +1182,7 @@ RSpec.describe "bundle update --bundler" do
end end
it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do
pristine_system_gems "bundler-2.3.3" pristine_system_gems "bundler-2.3.9"
build_repo4 do build_repo4 do
build_gem "rack", "1.0" build_gem "rack", "1.0"
@ -1192,16 +1192,16 @@ RSpec.describe "bundle update --bundler" do
source "#{file_uri_for(gem_repo4)}" source "#{file_uri_for(gem_repo4)}"
gem "rack" gem "rack"
G G
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9")
bundle :update, :bundler => true, :artifice => "vcr", :verbose => true bundle :update, :bundler => true, :artifice => "vcr", :verbose => true
# Only updates properly on modern RubyGems. # Only updates properly on modern RubyGems.
if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev") if Gem.rubygems_version >= Gem::Version.new("3.3.0.dev")
expect(out).to include("Updating bundler to 2.3.4") expect(out).to include("Updating bundler to 2.3.10")
expect(out).to include("Using bundler 2.3.4") expect(out).to include("Using bundler 2.3.10")
expect(out).not_to include("Installing Bundler 2.3.3 and restarting using that version.") expect(out).not_to include("Installing Bundler 2.3.9 and restarting using that version.")
expect(lockfile).to eq <<~L expect(lockfile).to eq <<~L
GEM GEM
@ -1216,17 +1216,17 @@ RSpec.describe "bundle update --bundler" do
rack rack
BUNDLED WITH BUNDLED WITH
2.3.4 2.3.10
L L
expect(the_bundle).to include_gems "bundler 2.3.4" expect(the_bundle).to include_gems "bundler 2.3.10"
end end
expect(the_bundle).to include_gems "rack 1.0" expect(the_bundle).to include_gems "rack 1.0"
end end
it "errors if the explicit target version does not exist", :realworld do it "errors if the explicit target version does not exist", :realworld do
pristine_system_gems "bundler-2.3.3" pristine_system_gems "bundler-2.3.9"
build_repo4 do build_repo4 do
build_gem "rack", "1.0" build_gem "rack", "1.0"
@ -1236,7 +1236,7 @@ RSpec.describe "bundle update --bundler" do
source "#{file_uri_for(gem_repo4)}" source "#{file_uri_for(gem_repo4)}"
gem "rack" gem "rack"
G G
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.3") lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, "2.3.9")
bundle :update, :bundler => "999.999.999", :artifice => "vcr", :raise_on_error => false bundle :update, :bundler => "999.999.999", :artifice => "vcr", :raise_on_error => false
@ -1286,7 +1286,7 @@ RSpec.describe "bundle update --bundler" do
end end
it "does not touch the network if not necessary" do it "does not touch the network if not necessary" do
system_gems "bundler-2.3.3" system_gems "bundler-2.3.9"
build_repo4 do build_repo4 do
build_gem "rack", "1.0" build_gem "rack", "1.0"
@ -1297,7 +1297,7 @@ RSpec.describe "bundle update --bundler" do
gem "rack" gem "rack"
G G
bundle :update, :bundler => "2.3.3", :raise_on_error => false bundle :update, :bundler => "2.3.9", :raise_on_error => false
expect(out).not_to include("Fetching gem metadata from https://rubygems.org/") expect(out).not_to include("Fetching gem metadata from https://rubygems.org/")
@ -1317,10 +1317,10 @@ RSpec.describe "bundle update --bundler" do
rack rack
BUNDLED WITH BUNDLED WITH
2.3.3 2.3.9
L L
expect(out).to include("Using bundler 2.3.3") expect(out).to include("Using bundler 2.3.9")
end end
end end
end end

View file

@ -1180,7 +1180,7 @@ RSpec.describe "bundle install with git sources" do
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/foo.rb", "w") do |f| File.open("\#{path}/foo.rb", "w") do |f|
f.puts "FOO = 'YES'" f.puts "FOO = 'YES'"
@ -1273,7 +1273,7 @@ In Gemfile:
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
cur_time = Time.now.to_f.to_s cur_time = Time.now.to_f.to_s
File.open("\#{path}/foo.rb", "w") do |f| File.open("\#{path}/foo.rb", "w") do |f|
@ -1314,7 +1314,7 @@ In Gemfile:
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
cur_time = Time.now.to_f.to_s cur_time = Time.now.to_f.to_s
File.open("\#{path}/foo.rb", "w") do |f| File.open("\#{path}/foo.rb", "w") do |f|
@ -1357,7 +1357,7 @@ In Gemfile:
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
cur_time = Time.now.to_f.to_s cur_time = Time.now.to_f.to_s
File.open("\#{path}/foo.rb", "w") do |f| File.open("\#{path}/foo.rb", "w") do |f|

View file

@ -137,7 +137,7 @@ RSpec.describe "bundle install with explicit source paths" do
install_gemfile <<-G install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo1)}"
gem 'foo', :path => File.expand_path("../foo-1.0", __FILE__) gem 'foo', :path => File.expand_path("foo-1.0", __dir__)
G G
bundle "config set --local frozen true" bundle "config set --local frozen true"

View file

@ -258,7 +258,7 @@ The checksum of /versions does not match the checksum provided by the server! So
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/net_build_extensions.rb", "w") do |f| File.open("\#{path}/net_build_extensions.rb", "w") do |f|
f.puts "NET_BUILD_EXTENSIONS = 'YES'" f.puts "NET_BUILD_EXTENSIONS = 'YES'"

View file

@ -7,7 +7,7 @@ RSpec.describe "bundle install with install-time dependencies" do
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/implicit_rake_dep.rb", "w") do |f| File.open("\#{path}/implicit_rake_dep.rb", "w") do |f|
f.puts "IMPLICIT_RAKE_DEP = 'YES'" f.puts "IMPLICIT_RAKE_DEP = 'YES'"
@ -20,7 +20,7 @@ RSpec.describe "bundle install with install-time dependencies" do
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f| File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f|
f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'" f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'"
@ -42,7 +42,7 @@ RSpec.describe "bundle install with install-time dependencies" do
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/net_build_extensions.rb", "w") do |f| File.open("\#{path}/net_build_extensions.rb", "w") do |f|
f.puts "NET_BUILD_EXTENSIONS = 'YES'" f.puts "NET_BUILD_EXTENSIONS = 'YES'"

View file

@ -205,7 +205,7 @@ RSpec.shared_examples "bundle install --standalone" do
build_git "bar", :gemspec => false do |s| build_git "bar", :gemspec => false do |s|
s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0') s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
s.write "bar.gemspec", <<-G s.write "bar.gemspec", <<-G
lib = File.expand_path('../lib/', __FILE__) lib = File.expand_path('lib/', __dir__)
$:.unshift lib unless $:.include?(lib) $:.unshift lib unless $:.include?(lib)
require 'bar/version' require 'bar/version'
@ -419,7 +419,7 @@ RSpec.shared_examples "bundle install --standalone" do
it "creates stubs with the correct load path" do it "creates stubs with the correct load path" do
extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip
expect(extension_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath) expect(extension_line).to eq %($:.unshift File.expand_path "../bundle", __dir__)
end end
end end
end end

View file

@ -54,7 +54,7 @@ RSpec.describe "when using sudo", :sudo => true do
s.extensions << "Rakefile" s.extensions << "Rakefile"
s.write "Rakefile", <<-RUBY s.write "Rakefile", <<-RUBY
task :default do task :default do
path = File.expand_path("../lib", __FILE__) path = File.expand_path("lib", __dir__)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f| File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f|
f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'" f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'"

View file

@ -897,7 +897,7 @@ RSpec.describe "the lockfile format" do
install_gemfile <<-G install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo1)}"
path File.expand_path("../foo", __FILE__) do path File.expand_path("foo", __dir__) do
gem "foo" gem "foo"
end end
G G

View file

@ -3,7 +3,7 @@
require 'rubygems' require 'rubygems'
# If bundler gemspec exists, add to stubs # If bundler gemspec exists, add to stubs
bundler_gemspec = File.expand_path("../../../bundler/bundler.gemspec", __FILE__) 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) Gem::Specification.dirs.unshift File.dirname(bundler_gemspec)
Gem::Specification.class_variable_set :@@stubs, nil Gem::Specification.class_variable_set :@@stubs, nil

View file

@ -10,7 +10,7 @@ require 'rbconfig'
class TestGem < Gem::TestCase class TestGem < Gem::TestCase
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT) PROJECT_DIR = File.expand_path('../..', __dir__).tap(&Gem::UNTAINT)
def setup def setup
super super

View file

@ -3,7 +3,7 @@ require_relative 'helper'
require 'rubygems/command_manager' require 'rubygems/command_manager'
class TestGemCommandManager < Gem::TestCase class TestGemCommandManager < Gem::TestCase
PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT) PROJECT_DIR = File.expand_path('../..', __dir__).tap(&Gem::UNTAINT)
def setup def setup
super super

View file

@ -11,7 +11,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
@cmd = Gem::Commands::HelpCommand.new @cmd = Gem::Commands::HelpCommand.new
load File.expand_path('../rubygems_plugin.rb', __FILE__) unless Gem::Commands.const_defined? :InterruptCommand load File.expand_path('rubygems_plugin.rb', __dir__) unless Gem::Commands.const_defined? :InterruptCommand
end end
def test_gem_help_bad def test_gem_help_bad

View file

@ -4,7 +4,7 @@ require_relative 'helper'
require 'rubygems/commands/setup_command' require 'rubygems/commands/setup_command'
class TestGemCommandsSetupCommand < Gem::TestCase class TestGemCommandsSetupCommand < Gem::TestCase
bundler_gemspec = File.expand_path("../../../bundler/lib/bundler/version.rb", __FILE__) bundler_gemspec = File.expand_path('../../bundler/lib/bundler/version.rb', __dir__)
if File.exist?(bundler_gemspec) if File.exist?(bundler_gemspec)
BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1] BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
else else

View file

@ -941,7 +941,7 @@ class TestGemDependencyInstaller < Gem::TestCase
end end
def test_install_legacy_spec_with_nil_required_ruby_version def test_install_legacy_spec_with_nil_required_ruby_version
path = File.expand_path "../data/null-required-ruby-version.gemspec.rz", __FILE__ path = File.expand_path 'data/null-required-ruby-version.gemspec.rz', __dir__
spec = Marshal.load Gem.read_binary(path) spec = Marshal.load Gem.read_binary(path)
def spec.validate(*args); end def spec.validate(*args); end
@ -966,7 +966,7 @@ class TestGemDependencyInstaller < Gem::TestCase
end end
def test_install_legacy_spec_with_nil_required_rubygems_version def test_install_legacy_spec_with_nil_required_rubygems_version
path = File.expand_path "../data/null-required-rubygems-version.gemspec.rz", __FILE__ path = File.expand_path 'data/null-required-rubygems-version.gemspec.rz', __dir__
spec = Marshal.load Gem.read_binary(path) spec = Marshal.load Gem.read_binary(path)
def spec.validate(*args); end def spec.validate(*args); end

View file

@ -291,7 +291,7 @@ install:
File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f| File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f|
f.write <<-'RUBY' f.write <<-'RUBY'
puts "IN EXTCONF" puts "IN EXTCONF"
extconf_args = File.join File.dirname(__FILE__), 'extconf_args' extconf_args = File.join __dir__, 'extconf_args'
File.open extconf_args, 'w' do |f| File.open extconf_args, 'w' do |f|
f.puts ARGV.inspect f.puts ARGV.inspect
end end

View file

@ -20,7 +20,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
def setup_rust_gem(name) def setup_rust_gem(name)
@ext = File.join(@tempdir, 'ext') @ext = File.join(@tempdir, 'ext')
@dest_path = File.join(@tempdir, 'prefix') @dest_path = File.join(@tempdir, 'prefix')
@fixture_dir = Pathname.new(File.expand_path("../test_gem_ext_cargo_builder/#{name}/", __FILE__)) @fixture_dir = Pathname.new(File.expand_path("test_gem_ext_cargo_builder/#{name}/", __dir__))
FileUtils.mkdir_p @dest_path FileUtils.mkdir_p @dest_path
FileUtils.cp_r(@fixture_dir.to_s, @ext) FileUtils.cp_r(@fixture_dir.to_s, @ext)
@ -103,7 +103,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
Dir.chdir @ext do Dir.chdir @ext do
require 'tmpdir' require 'tmpdir'
gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path("./../../../bin/gem", __FILE__)] gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("rust_ruby_example") do |dir| Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem")) built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
@ -125,7 +125,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
Dir.chdir @ext do Dir.chdir @ext do
require 'tmpdir' require 'tmpdir'
gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path("./../../../bin/gem", __FILE__)] gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("custom_name") do |dir| Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem")) built_gem = File.expand_path(File.join(dir, "custom_name.gem"))

View file

@ -9,9 +9,9 @@ end
require 'tmpdir' require 'tmpdir'
lp = File.expand_path("./../../../../../lib", __FILE__) lp = File.expand_path('../../../../lib', __dir__)
gem = ["ruby", "-I#{lp}", File.expand_path("./../../../../../bin/gem", __FILE__)] gem = ["ruby", "-I#{lp}", File.expand_path('../../../../bin/gem', __dir__)]
gemspec = File.expand_path("./../custom_name.gemspec", __FILE__) gemspec = File.expand_path('custom_name.gemspec', __dir__)
Dir.mktmpdir("custom_name") do |dir| Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem")) built_gem = File.expand_path(File.join(dir, "custom_name.gem"))

View file

@ -9,9 +9,9 @@ end
require 'tmpdir' require 'tmpdir'
lp = File.expand_path("./../../../../../lib", __FILE__) lp = File.expand_path('../../../../lib', __dir__)
gem = ["ruby", "-I#{lp}", File.expand_path("./../../../../../bin/gem", __FILE__)] gem = ["ruby", "-I#{lp}", File.expand_path('../../../../bin/gem', __dir__)]
gemspec = File.expand_path("./../rust_ruby_example.gemspec", __FILE__) gemspec = File.expand_path('rust_ruby_example.gemspec', __dir__)
Dir.mktmpdir("rust_ruby_example") do |dir| Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem")) built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))

View file

@ -1068,7 +1068,7 @@ dependencies: []
end end
def test_handles_private_null_type def test_handles_private_null_type
path = File.expand_path "../data/null-type.gemspec.rz", __FILE__ path = File.expand_path 'data/null-type.gemspec.rz', __dir__
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path)) data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))

View file

@ -5,7 +5,7 @@ require "open3"
class TestProjectSanity < Gem::TestCase class TestProjectSanity < Gem::TestCase
def test_manifest_is_up_to_date def test_manifest_is_up_to_date
pend unless File.exist?(File.expand_path("../../../Rakefile", __FILE__)) pend unless File.exist?(File.expand_path('../../Rakefile', __dir__))
_, status = Open3.capture2e("rake check_manifest") _, status = Open3.capture2e("rake check_manifest")

View file

@ -230,7 +230,7 @@ class TestGemRequire < Gem::TestCase
pend "not installed yet" unless RbConfig::TOPDIR pend "not installed yet" unless RbConfig::TOPDIR
lib_dir = File.expand_path("../../lib", File.dirname(__FILE__)) lib_dir = File.expand_path("../lib", __dir__)
rubylibdir = File.realdirpath(RbConfig::CONFIG["rubylibdir"]) rubylibdir = File.realdirpath(RbConfig::CONFIG["rubylibdir"])
if rubylibdir == lib_dir if rubylibdir == lib_dir
# testing in the ruby repository where RubyGems' lib/ == stdlib lib/ # testing in the ruby repository where RubyGems' lib/ == stdlib lib/