From 52e867268e1ecf91a3a4b3b8d587ba4c37e17f9c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 15 Nov 2024 11:49:30 +0900 Subject: [PATCH] Port test_warn_sub_feature.rb to RSpec example --- lib/bundled_gems.rb | 5 +++-- spec/bundler/bundled_gems_spec.rb | 12 ++++++++++++ tool/test_for_warn_bundled_gems/test.sh | 4 ---- .../test_warn_sub_feature.rb | 10 ---------- 4 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 tool/test_for_warn_bundled_gems/test_warn_sub_feature.rb diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb index 940abd376c..9b0fc90a27 100644 --- a/lib/bundled_gems.rb +++ b/lib/bundled_gems.rb @@ -55,10 +55,11 @@ module Gem::BUNDLED_GEMS conf = ::RbConfig::CONFIG if ENV["TEST_BUNDLED_GEMS"] LIBDIR = (File.expand_path(File.join(__dir__, "..", "lib")) + "/").freeze + ARCHDIR = (File.expand_path(File.join(__dir__, "..", ".ext/common")) + "/").freeze else LIBDIR = (conf["rubylibdir"] + "/").freeze + ARCHDIR = (conf["rubyarchdir"] + "/").freeze end - ARCHDIR = (conf["rubyarchdir"] + "/").freeze dlext = [conf["DLEXT"], "so"].uniq DLEXT = /\.#{Regexp.union(dlext)}\z/ LIBEXT = /\.#{Regexp.union("rb", *dlext)}\z/ @@ -122,7 +123,7 @@ module Gem::BUNDLED_GEMS if !path return elsif path.start_with?(ARCHDIR) - n = path.delete_prefix(ARCHDIR).sub(DLEXT, "") + n = path.delete_prefix(ARCHDIR).sub(DLEXT, "").chomp(".rb") elsif path.start_with?(LIBDIR) n = path.delete_prefix(LIBDIR).chomp(".rb") else diff --git a/spec/bundler/bundled_gems_spec.rb b/spec/bundler/bundled_gems_spec.rb index 05f669d717..e0381548f1 100644 --- a/spec/bundler/bundled_gems_spec.rb +++ b/spec/bundler/bundled_gems_spec.rb @@ -62,6 +62,18 @@ RSpec.describe "bundled_gems.rb" do expect(err).to include("You can add net-smtp") end + it "Show warning sub-feature like fiddle/import" do + script <<-RUBY + gemfile do + source "https://rubygems.org" + end + + require "fiddle/import" + RUBY + + expect(err).to include(/fiddle was loaded from (.*) from Ruby 3.5.0/) + end + it "Show warning when bundle exec with ruby and script" do code = <<-RUBY require "ostruct" diff --git a/tool/test_for_warn_bundled_gems/test.sh b/tool/test_for_warn_bundled_gems/test.sh index 3813a4d268..0cdfcbf075 100755 --- a/tool/test_for_warn_bundled_gems/test.sh +++ b/tool/test_for_warn_bundled_gems/test.sh @@ -1,9 +1,5 @@ #!/bin/bash -echo "* Show warning sub-feature like bigdecimal/util" -ruby test_warn_sub_feature.rb -echo - echo "* Show warning with bootsnap" ruby test_warn_bootsnap.rb echo diff --git a/tool/test_for_warn_bundled_gems/test_warn_sub_feature.rb b/tool/test_for_warn_bundled_gems/test_warn_sub_feature.rb deleted file mode 100644 index 586a8a13be..0000000000 --- a/tool/test_for_warn_bundled_gems/test_warn_sub_feature.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "bundler" -Bundler::Definition.no_lock = true - -require "bundler/inline" - -gemfile do - source "https://rubygems.org" -end - -require "bigdecimal/util"