Update to ruby/mspec@231e2ce
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6c574d4be4
commit
820f99791e
@ -18,20 +18,20 @@ class PlatformGuard < SpecGuard
|
|||||||
implementation? :ruby
|
implementation? :ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
HOST_OS = begin
|
PLATFORM = if RUBY_ENGINE == "jruby"
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
RbConfig::CONFIG['host_os'] || RUBY_PLATFORM
|
"#{RbConfig::CONFIG['host_cpu']}-#{RbConfig::CONFIG['host_os']}"
|
||||||
rescue LoadError
|
else
|
||||||
RUBY_PLATFORM
|
RUBY_PLATFORM
|
||||||
end.downcase
|
end
|
||||||
|
|
||||||
def self.os?(*oses)
|
def self.os?(*oses)
|
||||||
oses.any? do |os|
|
oses.any? do |os|
|
||||||
raise ":java is not a valid OS" if os == :java
|
raise ":java is not a valid OS" if os == :java
|
||||||
if os == :windows
|
if os == :windows
|
||||||
HOST_OS =~ /(mswin|mingw)/
|
PLATFORM =~ /(mswin|mingw)/
|
||||||
else
|
else
|
||||||
HOST_OS.include?(os.to_s)
|
PLATFORM.include?(os.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -197,7 +197,7 @@ end
|
|||||||
|
|
||||||
describe PlatformGuard, ".os?" do
|
describe PlatformGuard, ".os?" do
|
||||||
before :each do
|
before :each do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'solarce'
|
stub_const 'PlatformGuard::PLATFORM', 'solarce'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when arg does not match the platform" do
|
it "returns false when arg does not match the platform" do
|
||||||
@ -217,26 +217,36 @@ describe PlatformGuard, ".os?" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when arg is :windows and the platform contains 'mswin'" do
|
it "returns true when arg is :windows and the platform contains 'mswin'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'mswin32'
|
stub_const 'PlatformGuard::PLATFORM', 'mswin32'
|
||||||
PlatformGuard.os?(:windows).should == true
|
PlatformGuard.os?(:windows).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when arg is :windows and the platform contains 'mingw'" do
|
it "returns true when arg is :windows and the platform contains 'mingw'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.os?(:windows).should == true
|
PlatformGuard.os?(:windows).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'
|
||||||
PlatformGuard.os?(:linux).should == false
|
PlatformGuard.os?(:linux).should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.os?(:linux).should == false
|
PlatformGuard.os?(:linux).should == false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe PlatformGuard, ".os?" do
|
||||||
|
it "returns true if called with the current OS or architecture" do
|
||||||
|
os = RbConfig::CONFIG["host_os"].sub("-gnu", "")
|
||||||
|
arch = RbConfig::CONFIG["host_arch"]
|
||||||
|
PlatformGuard.os?(os).should == true
|
||||||
|
PlatformGuard.os?(arch).should == true
|
||||||
|
PlatformGuard.os?("#{arch}-#{os}").should == true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe PlatformGuard, ".os? on JRuby" do
|
describe PlatformGuard, ".os? on JRuby" do
|
||||||
before :all do
|
before :all do
|
||||||
@verbose = $VERBOSE
|
@verbose = $VERBOSE
|
||||||
@ -263,19 +273,19 @@ describe PlatformGuard, ".os? on JRuby" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do
|
it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'mswin32'
|
stub_const 'PlatformGuard::PLATFORM', 'mswin32'
|
||||||
PlatformGuard.os?(:windows).should == true
|
PlatformGuard.os?(:windows).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do
|
it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'amiga'
|
stub_const 'PlatformGuard::PLATFORM', 'amiga'
|
||||||
PlatformGuard.os?(:amiga).should == true
|
PlatformGuard.os?(:amiga).should == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe PlatformGuard, ".os?" do
|
describe PlatformGuard, ".os?" do
|
||||||
before :each do
|
before :each do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'unreal'
|
stub_const 'PlatformGuard::PLATFORM', 'unreal'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if argument matches RbConfig::CONFIG['host_os']" do
|
it "returns true if argument matches RbConfig::CONFIG['host_os']" do
|
||||||
@ -295,34 +305,34 @@ describe PlatformGuard, ".os?" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'
|
||||||
PlatformGuard.os?(:windows).should == true
|
PlatformGuard.os?(:windows).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.os?(:windows).should == true
|
PlatformGuard.os?(:windows).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.os?(:linux).should == false
|
PlatformGuard.os?(:linux).should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.os?(:linux).should == false
|
PlatformGuard.os?(:linux).should == false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe PlatformGuard, ".windows?" do
|
describe PlatformGuard, ".windows?" do
|
||||||
it "returns true on windows" do
|
it "returns true on windows" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32'
|
stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'
|
||||||
PlatformGuard.windows?.should == true
|
PlatformGuard.windows?.should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false on non-windows" do
|
it "returns false on non-windows" do
|
||||||
stub_const 'PlatformGuard::HOST_OS', 'i586-linux'
|
stub_const 'PlatformGuard::PLATFORM', 'i586-linux'
|
||||||
PlatformGuard.windows?.should == false
|
PlatformGuard.windows?.should == false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user