Port test_warn_bootsnap_and_gem.rb to RSpec example

This commit is contained in:
Hiroshi SHIBATA 2024-11-15 14:52:13 +09:00
Родитель 5395afd422
Коммит 5bd0dfbf2e
3 изменённых файлов: 30 добавлений и 18 удалений

Просмотреть файл

@ -193,6 +193,36 @@ RSpec.describe "bundled_gems.rb" do
# test_warn_bootsnap_rubyarchdir_gem.rb:14: warning: ...
end
it "Show warning with bootsnap and some gem in Gemfile" do
build_lib "childprocess", "5.0.0" do |s|
# bootsnap expand required feature to full path
# require 'logger'
rubylibpath = File.expand_path(File.join(__dir__, "..", "..", "lib"))
s.write "lib/childprocess.rb", "require '#{rubylibpath}/logger'"
end
script <<-RUBY
gemfile do
source "https://rubygems.org"
# gem "bootsnap", require: false
path "#{lib_path}" do
gem "childprocess", "5.0.0"
end
end
# require 'bootsnap'
# Bootsnap.setup(cache_dir: 'tmp/cache')
# bootsnap expand required feature to full path
# require 'childprocess'
require Gem.loaded_specs["childprocess"].full_gem_path + '/lib/childprocess'
RUBY
expect(err).to include(/logger was loaded from (.*) from Ruby 3.5.0/)
# TODO: We should assert caller location like below:
# $GEM_HOME/gems/childprocess-5.0.0/lib/childprocess.rb:7: warning:
end
it "Don't show warning fiddle/import when fiddle on Gemfile" do
build_lib "fiddle", "1.0.0" do |s|
s.write "lib/fiddle.rb", "puts 'fiddle'"

Просмотреть файл

@ -3,7 +3,3 @@
echo "* Show warning with zeitwerk"
ruby test_warn_zeitwerk.rb
echo
echo "* Show warning with bootsnap and some gem in Gemfile"
ruby test_warn_bootsnap_and_gem.rb
echo

Просмотреть файл

@ -1,14 +0,0 @@
require "bundler"
Bundler::Definition.no_lock = true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "bootsnap", require: false
gem "childprocess", "5.0.0", require: false # Has undeclared logger dependency
end
ENV["BOOTSNAP_CACHE_DIR"] ||= "tmp/cache/bootsnap"
require "bootsnap/setup"
require "childprocess"