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

[bundler/bundler] RUBY_ENGINE should always be defined after 1.8.7

https://github.com/bundler/bundler/commit/d6c9196d18
This commit is contained in:
David Rodríguez 2019-04-12 19:05:26 +02:00 committed by Hiroshi SHIBATA
parent d2d6d5c988
commit 7255f55dba
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
6 changed files with 16 additions and 33 deletions

View file

@ -38,28 +38,27 @@ module Bundler
].freeze ].freeze
def ruby? def ruby?
!mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || !mswin? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
end end
def mri? def mri?
!mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") !mswin? && RUBY_ENGINE == "ruby"
end end
def rbx? def rbx?
ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx" ruby? && RUBY_ENGINE == "rbx"
end end
def jruby? def jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" RUBY_ENGINE == "jruby"
end end
def maglev? def maglev?
defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev" RUBY_ENGINE == "maglev"
end end
def truffleruby? def truffleruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == "truffleruby" RUBY_ENGINE == "truffleruby"
end end
def mswin? def mswin?

View file

@ -12,8 +12,7 @@ module Bundler
end end
File.open File.join(bundler_path, "setup.rb"), "w" do |file| File.open File.join(bundler_path, "setup.rb"), "w" do |file|
file.puts "require 'rbconfig'" file.puts "require 'rbconfig'"
file.puts "# ruby 1.8.7 doesn't define RUBY_ENGINE" file.puts "ruby_engine = RUBY_ENGINE"
file.puts "ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'"
file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]" file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
file.puts "path = File.expand_path('..', __FILE__)" file.puts "path = File.expand_path('..', __FILE__)"
paths.each do |path| paths.each do |path|

View file

@ -102,12 +102,7 @@ module Bundler
end end
def self.system def self.system
ruby_engine = if defined?(RUBY_ENGINE) && !RUBY_ENGINE.nil? ruby_engine = RUBY_ENGINE.dup
RUBY_ENGINE.dup
else
# not defined in ruby 1.8.7
"ruby"
end
# :sob: mocking RUBY_VERSION breaks stuff on 1.8.7 # :sob: mocking RUBY_VERSION breaks stuff on 1.8.7
ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
ruby_engine_version = case ruby_engine ruby_engine_version = case ruby_engine

View file

@ -426,22 +426,12 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
end end
describe "#engine" do describe "#engine" do
context "RUBY_ENGINE is defined" do before { stub_const("RUBY_ENGINE", "jruby") }
before { stub_const("RUBY_ENGINE", "jruby") } before { stub_const("JRUBY_VERSION", "2.1.1") }
before { stub_const("JRUBY_VERSION", "2.1.1") }
it "should return a copy of the value of RUBY_ENGINE" do it "should return a copy of the value of RUBY_ENGINE" do
expect(subject.engine).to eq("jruby") expect(subject.engine).to eq("jruby")
expect(subject.engine).to_not be(RUBY_ENGINE) expect(subject.engine).to_not be(RUBY_ENGINE)
end
end
context "RUBY_ENGINE is not defined" do
before { stub_const("RUBY_ENGINE", nil) }
it "should return the string 'ruby'" do
expect(subject.engine).to eq("ruby")
end
end end
end end

View file

@ -40,7 +40,7 @@ end
class Object class Object
if ENV["BUNDLER_SPEC_RUBY_ENGINE"] if ENV["BUNDLER_SPEC_RUBY_ENGINE"]
if defined?(RUBY_ENGINE) && RUBY_ENGINE != "jruby" && ENV["BUNDLER_SPEC_RUBY_ENGINE"] == "jruby" if RUBY_ENGINE != "jruby" && ENV["BUNDLER_SPEC_RUBY_ENGINE"] == "jruby"
begin begin
# this has to be done up front because psych will try to load a .jar # this has to be done up front because psych will try to load a .jar
# if it thinks its on jruby # if it thinks its on jruby
@ -50,7 +50,7 @@ class Object
end end
end end
remove_const :RUBY_ENGINE if defined?(RUBY_ENGINE) remove_const :RUBY_ENGINE
RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"] RUBY_ENGINE = ENV["BUNDLER_SPEC_RUBY_ENGINE"]
if RUBY_ENGINE == "jruby" if RUBY_ENGINE == "jruby"

View file

@ -65,7 +65,7 @@ module Spec
end end
def local_ruby_engine def local_ruby_engine
ENV["BUNDLER_SPEC_RUBY_ENGINE"] || (defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby") ENV["BUNDLER_SPEC_RUBY_ENGINE"] || RUBY_ENGINE
end end
def local_engine_version def local_engine_version