mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/mspec@d900a49
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bd8412b74f
commit
5ccf36c7ec
41 changed files with 547 additions and 650 deletions
|
@ -22,7 +22,6 @@ class MSpecCI < MSpecScript
|
||||||
options.chdir
|
options.chdir
|
||||||
options.prefix
|
options.prefix
|
||||||
options.configure { |f| load f }
|
options.configure { |f| load f }
|
||||||
options.name
|
|
||||||
options.pretend
|
options.pretend
|
||||||
options.interrupt
|
options.interrupt
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ class MSpecRun < MSpecScript
|
||||||
options.chdir
|
options.chdir
|
||||||
options.prefix
|
options.prefix
|
||||||
options.configure { |f| load f }
|
options.configure { |f| load f }
|
||||||
options.name
|
|
||||||
options.randomize
|
options.randomize
|
||||||
options.repeat
|
options.repeat
|
||||||
options.pretend
|
options.pretend
|
||||||
|
|
|
@ -30,7 +30,6 @@ class MSpecTag < MSpecScript
|
||||||
|
|
||||||
options.doc "\n How to modify the execution"
|
options.doc "\n How to modify the execution"
|
||||||
options.configure { |f| load f }
|
options.configure { |f| load f }
|
||||||
options.name
|
|
||||||
options.pretend
|
options.pretend
|
||||||
options.unguarded
|
options.unguarded
|
||||||
options.interrupt
|
options.interrupt
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'mspec/utils/ruby_name'
|
|
||||||
require 'mspec/guards/block_device'
|
require 'mspec/guards/block_device'
|
||||||
require 'mspec/guards/bug'
|
require 'mspec/guards/bug'
|
||||||
require 'mspec/guards/conflict'
|
require 'mspec/guards/conflict'
|
||||||
|
|
|
@ -11,8 +11,6 @@ class BlockDeviceGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def with_block_device(&block)
|
||||||
def with_block_device(&block)
|
|
||||||
BlockDeviceGuard.new.run_if(:with_block_device, &block)
|
BlockDeviceGuard.new.run_if(:with_block_device, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,8 +23,6 @@ class BugGuard < VersionGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def ruby_bug(bug, version, &block)
|
||||||
def ruby_bug(bug, version, &block)
|
|
||||||
BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
|
BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,12 +8,10 @@ class ConflictsGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
# In some cases, libraries will modify another Ruby method's
|
||||||
# In some cases, libraries will modify another Ruby method's
|
# behavior. The specs for the method's behavior will then fail
|
||||||
# behavior. The specs for the method's behavior will then fail
|
# if that library is loaded. This guard will not run if any of
|
||||||
# if that library is loaded. This guard will not run if any of
|
# the specified constants exist in Object.constants.
|
||||||
# the specified constants exist in Object.constants.
|
def conflicts_with(*modules, &block)
|
||||||
def conflicts_with(*modules, &block)
|
|
||||||
ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
|
ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,12 +16,10 @@ class BigEndianGuard < EndianGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def big_endian(&block)
|
||||||
def big_endian(&block)
|
|
||||||
BigEndianGuard.new.run_if(:big_endian, &block)
|
BigEndianGuard.new.run_if(:big_endian, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def little_endian(&block)
|
def little_endian(&block)
|
||||||
BigEndianGuard.new.run_unless(:little_endian, &block)
|
BigEndianGuard.new.run_unless(:little_endian, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,34 +10,32 @@ class FeatureGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
# Provides better documentation in the specs by
|
||||||
# Provides better documentation in the specs by
|
# naming sets of features that work together as
|
||||||
# naming sets of features that work together as
|
# a whole. Examples include :encoding, :fiber,
|
||||||
# a whole. Examples include :encoding, :fiber,
|
# :continuation, :fork.
|
||||||
# :continuation, :fork.
|
#
|
||||||
#
|
# Usage example:
|
||||||
# Usage example:
|
#
|
||||||
#
|
# with_feature :encoding do
|
||||||
# with_feature :encoding do
|
# # specs for a method that provides aspects
|
||||||
# # specs for a method that provides aspects
|
# # of the encoding feature
|
||||||
# # of the encoding feature
|
# end
|
||||||
# end
|
#
|
||||||
#
|
# Multiple features must all be enabled for the
|
||||||
# Multiple features must all be enabled for the
|
# guard to run:
|
||||||
# guard to run:
|
#
|
||||||
#
|
# with_feature :one, :two do
|
||||||
# with_feature :one, :two do
|
# # these specs will run if features :one AND
|
||||||
# # these specs will run if features :one AND
|
# # :two are enabled.
|
||||||
# # :two are enabled.
|
# end
|
||||||
# end
|
#
|
||||||
#
|
# The implementation must explicitly enable a feature
|
||||||
# The implementation must explicitly enable a feature
|
# by adding code like the following to the .mspec
|
||||||
# by adding code like the following to the .mspec
|
# configuration file:
|
||||||
# configuration file:
|
#
|
||||||
#
|
# MSpec.enable_feature :encoding
|
||||||
# MSpec.enable_feature :encoding
|
#
|
||||||
#
|
def with_feature(*features, &block)
|
||||||
def with_feature(*features, &block)
|
|
||||||
FeatureGuard.new(*features).run_if(:with_feature, &block)
|
FeatureGuard.new(*features).run_if(:with_feature, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
require 'mspec/runner/mspec'
|
require 'mspec/runner/mspec'
|
||||||
require 'mspec/runner/actions/tally'
|
require 'mspec/runner/actions/tally'
|
||||||
require 'mspec/utils/ruby_name'
|
|
||||||
|
|
||||||
class SpecGuard
|
class SpecGuard
|
||||||
def self.report
|
def self.report
|
||||||
|
|
|
@ -5,9 +5,9 @@ class PlatformGuard < SpecGuard
|
||||||
args.any? do |name|
|
args.any? do |name|
|
||||||
case name
|
case name
|
||||||
when :rubinius
|
when :rubinius
|
||||||
RUBY_NAME.start_with?('rbx')
|
RUBY_ENGINE.start_with?('rbx')
|
||||||
when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
|
when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
|
||||||
RUBY_NAME.start_with?(name.to_s)
|
RUBY_ENGINE.start_with?(name.to_s)
|
||||||
else
|
else
|
||||||
raise "unknown implementation #{name}"
|
raise "unknown implementation #{name}"
|
||||||
end
|
end
|
||||||
|
@ -67,12 +67,10 @@ class PlatformGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def platform_is(*args, &block)
|
||||||
def platform_is(*args, &block)
|
|
||||||
PlatformGuard.new(*args).run_if(:platform_is, &block)
|
PlatformGuard.new(*args).run_if(:platform_is, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def platform_is_not(*args, &block)
|
def platform_is_not(*args, &block)
|
||||||
PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
|
PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,6 @@ class QuarantineGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def quarantine!(&block)
|
||||||
def quarantine!(&block)
|
|
||||||
QuarantineGuard.new.run_unless(:quarantine!, &block)
|
QuarantineGuard.new.run_unless(:quarantine!, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,12 +6,10 @@ class SuperUserGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def as_superuser(&block)
|
||||||
def as_superuser(&block)
|
|
||||||
SuperUserGuard.new.run_if(:as_superuser, &block)
|
SuperUserGuard.new.run_if(:as_superuser, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_user(&block)
|
def as_user(&block)
|
||||||
SuperUserGuard.new.run_unless(:as_user, &block)
|
SuperUserGuard.new.run_unless(:as_user, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,6 @@ class SupportedGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def not_supported_on(*args, &block)
|
||||||
def not_supported_on(*args, &block)
|
|
||||||
SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
|
SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,8 +32,6 @@ class VersionGuard < SpecGuard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def ruby_version_is(*args, &block)
|
||||||
def ruby_version_is(*args, &block)
|
|
||||||
VersionGuard.new(*args).run_if(:ruby_version_is, &block)
|
VersionGuard.new(*args).run_if(:ruby_version_is, &block)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
class Object
|
# Convenience helper for specs using ARGF.
|
||||||
# Convenience helper for specs using ARGF.
|
# Set @argf to an instance of ARGF.class with the given +argv+.
|
||||||
# Set @argf to an instance of ARGF.class with the given +argv+.
|
# That instance must be used instead of ARGF as ARGF is global
|
||||||
# That instance must be used instead of ARGF as ARGF is global
|
# and it is not always possible to reset its state correctly.
|
||||||
# and it is not always possible to reset its state correctly.
|
#
|
||||||
#
|
# The helper yields to the block and then close
|
||||||
# The helper yields to the block and then close
|
# the files open by the instance. Example:
|
||||||
# the files open by the instance. Example:
|
#
|
||||||
#
|
# describe "That" do
|
||||||
# describe "That" do
|
# it "does something" do
|
||||||
# it "does something" do
|
# argf ['a', 'b'] do
|
||||||
# argf ['a', 'b'] do
|
# # do something
|
||||||
# # do something
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
def argf(argv)
|
||||||
def argf(argv)
|
|
||||||
if argv.empty? or argv.length > 2
|
if argv.empty? or argv.length > 2
|
||||||
raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
|
raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
|
||||||
end
|
end
|
||||||
|
@ -33,5 +32,4 @@ class Object
|
||||||
@argf = nil
|
@argf = nil
|
||||||
@__mspec_saved_argf_file__ = nil
|
@__mspec_saved_argf_file__ = nil
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,34 +1,33 @@
|
||||||
class Object
|
# Convenience helper for altering ARGV. Saves the
|
||||||
# Convenience helper for altering ARGV. Saves the
|
# value of ARGV and sets it to +args+. If a block
|
||||||
# value of ARGV and sets it to +args+. If a block
|
# is given, yields to the block and then restores
|
||||||
# is given, yields to the block and then restores
|
# the value of ARGV. The previously saved value of
|
||||||
# the value of ARGV. The previously saved value of
|
# ARGV can be restored by passing +:restore+. The
|
||||||
# ARGV can be restored by passing +:restore+. The
|
# former is useful in a single spec. The latter is
|
||||||
# former is useful in a single spec. The latter is
|
# useful in before/after actions. For example:
|
||||||
# useful in before/after actions. For example:
|
#
|
||||||
#
|
# describe "This" do
|
||||||
# describe "This" do
|
# before do
|
||||||
# before do
|
# argv ['a', 'b']
|
||||||
# argv ['a', 'b']
|
# end
|
||||||
# end
|
#
|
||||||
#
|
# after do
|
||||||
# after do
|
# argv :restore
|
||||||
# argv :restore
|
# end
|
||||||
# end
|
#
|
||||||
#
|
# it "does something" do
|
||||||
# it "does something" do
|
# # do something
|
||||||
# # do something
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
#
|
||||||
#
|
# describe "That" do
|
||||||
# describe "That" do
|
# it "does something" do
|
||||||
# it "does something" do
|
# argv ['a', 'b'] do
|
||||||
# argv ['a', 'b'] do
|
# # do something
|
||||||
# # do something
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
def argv(args)
|
||||||
def argv(args)
|
|
||||||
if args == :restore
|
if args == :restore
|
||||||
ARGV.replace(@__mspec_saved_argv__ || [])
|
ARGV.replace(@__mspec_saved_argv__ || [])
|
||||||
else
|
else
|
||||||
|
@ -42,5 +41,4 @@ class Object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
class Object
|
# The new_datetime helper makes writing DateTime specs more simple by
|
||||||
# The new_datetime helper makes writing DateTime specs more simple by
|
# providing default constructor values and accepting a Hash of only the
|
||||||
# providing default constructor values and accepting a Hash of only the
|
# constructor values needed for the particular spec. For example:
|
||||||
# constructor values needed for the particular spec. For example:
|
#
|
||||||
#
|
# new_datetime :hour => 1, :minute => 20
|
||||||
# new_datetime :hour => 1, :minute => 20
|
#
|
||||||
#
|
# Possible keys are:
|
||||||
# Possible keys are:
|
# :year, :month, :day, :hour, :minute, :second, :offset and :sg.
|
||||||
# :year, :month, :day, :hour, :minute, :second, :offset and :sg.
|
def new_datetime(opts={})
|
||||||
|
|
||||||
def new_datetime(opts={})
|
|
||||||
require 'date'
|
require 'date'
|
||||||
|
|
||||||
value = {
|
value = {
|
||||||
|
@ -24,9 +22,9 @@ class Object
|
||||||
|
|
||||||
DateTime.new value[:year], value[:month], value[:day], value[:hour],
|
DateTime.new value[:year], value[:month], value[:day], value[:hour],
|
||||||
value[:minute], value[:second], value[:offset], value[:sg]
|
value[:minute], value[:second], value[:offset], value[:sg]
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_timezone(name, offset = nil, daylight_saving_zone = "")
|
def with_timezone(name, offset = nil, daylight_saving_zone = "")
|
||||||
zone = name.dup
|
zone = name.dup
|
||||||
|
|
||||||
if offset
|
if offset
|
||||||
|
@ -46,6 +44,4 @@ class Object
|
||||||
ensure
|
ensure
|
||||||
ENV["TZ"] = old
|
ENV["TZ"] = old
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
class Object
|
# Returns the name of a fixture file by adjoining the directory
|
||||||
# Returns the name of a fixture file by adjoining the directory
|
# of the +file+ argument with "fixtures" and the contents of the
|
||||||
# of the +file+ argument with "fixtures" and the contents of the
|
# +args+ array. For example,
|
||||||
# +args+ array. For example,
|
#
|
||||||
#
|
# +file+ == "some/example_spec.rb"
|
||||||
# +file+ == "some/example_spec.rb"
|
#
|
||||||
#
|
# and
|
||||||
# and
|
#
|
||||||
#
|
# +args+ == ["subdir", "file.txt"]
|
||||||
# +args+ == ["subdir", "file.txt"]
|
#
|
||||||
#
|
# then the result is the expanded path of
|
||||||
# then the result is the expanded path of
|
#
|
||||||
#
|
# "some/fixtures/subdir/file.txt".
|
||||||
# "some/fixtures/subdir/file.txt".
|
def fixture(file, *args)
|
||||||
def fixture(file, *args)
|
|
||||||
path = File.dirname(file)
|
path = File.dirname(file)
|
||||||
path = path[0..-7] if path[-7..-1] == "/shared"
|
path = path[0..-7] if path[-7..-1] == "/shared"
|
||||||
fixtures = path[-9..-1] == "/fixtures" ? "" : "fixtures"
|
fixtures = path[-9..-1] == "/fixtures" ? "" : "fixtures"
|
||||||
|
@ -22,5 +21,4 @@ class Object
|
||||||
path = File.expand_path(path)
|
path = File.expand_path(path)
|
||||||
end
|
end
|
||||||
File.join(path, fixtures, args)
|
File.join(path, fixtures, args)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
class Object
|
def flunk(msg="This example is a failure")
|
||||||
def flunk(msg="This example is a failure")
|
|
||||||
SpecExpectation.fail_with "Failed:", msg
|
SpecExpectation.fail_with "Failed:", msg
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
class Object
|
# Copies a file
|
||||||
# Copies a file
|
def cp(source, dest)
|
||||||
def cp(source, dest)
|
|
||||||
File.open(dest, "wb") do |d|
|
File.open(dest, "wb") do |d|
|
||||||
File.open(source, "rb") do |s|
|
File.open(source, "rb") do |s|
|
||||||
while data = s.read(1024)
|
while data = s.read(1024)
|
||||||
|
@ -8,10 +7,10 @@ class Object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates each directory in path that does not exist.
|
# Creates each directory in path that does not exist.
|
||||||
def mkdir_p(path)
|
def mkdir_p(path)
|
||||||
parts = File.expand_path(path).split %r[/|\\]
|
parts = File.expand_path(path).split %r[/|\\]
|
||||||
name = parts.shift
|
name = parts.shift
|
||||||
parts.each do |part|
|
parts.each do |part|
|
||||||
|
@ -33,12 +32,12 @@ class Object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Recursively removes all files and directories in +path+
|
# Recursively removes all files and directories in +path+
|
||||||
# if +path+ is a directory. Removes the file if +path+ is
|
# if +path+ is a directory. Removes the file if +path+ is
|
||||||
# a file.
|
# a file.
|
||||||
def rm_r(*paths)
|
def rm_r(*paths)
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
path = File.expand_path path
|
path = File.expand_path path
|
||||||
|
|
||||||
|
@ -58,15 +57,14 @@ class Object
|
||||||
File.delete path
|
File.delete path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a file +name+. Creates the directory for +name+
|
# Creates a file +name+. Creates the directory for +name+
|
||||||
# if it does not exist.
|
# if it does not exist.
|
||||||
def touch(name, mode="w")
|
def touch(name, mode="w")
|
||||||
mkdir_p File.dirname(name)
|
mkdir_p File.dirname(name)
|
||||||
|
|
||||||
File.open(name, mode) do |f|
|
File.open(name, mode) do |f|
|
||||||
yield f if block_given?
|
yield f if block_given?
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,11 +61,10 @@ class IOStub
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
# Creates a "bare" file descriptor (i.e. one that is not associated
|
||||||
# Creates a "bare" file descriptor (i.e. one that is not associated
|
# with any Ruby object). The file descriptor can safely be passed
|
||||||
# with any Ruby object). The file descriptor can safely be passed
|
# to IO.new without creating a Ruby object alias to the fd.
|
||||||
# to IO.new without creating a Ruby object alias to the fd.
|
def new_fd(name, mode="w:utf-8")
|
||||||
def new_fd(name, mode="w:utf-8")
|
|
||||||
mode = options_or_mode(mode)
|
mode = options_or_mode(mode)
|
||||||
|
|
||||||
if mode.kind_of? Hash
|
if mode.kind_of? Hash
|
||||||
|
@ -77,31 +76,31 @@ class Object
|
||||||
end
|
end
|
||||||
|
|
||||||
IO.sysopen name, fmode(mode)
|
IO.sysopen name, fmode(mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates an IO instance for a temporary file name. The file
|
# Creates an IO instance for a temporary file name. The file
|
||||||
# must be deleted.
|
# must be deleted.
|
||||||
def new_io(name, mode="w:utf-8")
|
def new_io(name, mode="w:utf-8")
|
||||||
IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
|
IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
# This helper simplifies passing file access modes regardless of
|
# This helper simplifies passing file access modes regardless of
|
||||||
# whether the :encoding feature is enabled. Only the access specifier
|
# whether the :encoding feature is enabled. Only the access specifier
|
||||||
# itself will be returned if :encoding is not enabled. Otherwise,
|
# itself will be returned if :encoding is not enabled. Otherwise,
|
||||||
# the full mode string will be returned (i.e. the helper is a no-op).
|
# the full mode string will be returned (i.e. the helper is a no-op).
|
||||||
def fmode(mode)
|
def fmode(mode)
|
||||||
if FeatureGuard.enabled? :encoding
|
if FeatureGuard.enabled? :encoding
|
||||||
mode
|
mode
|
||||||
else
|
else
|
||||||
mode.split(':').first
|
mode.split(':').first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This helper simplifies passing file access modes or options regardless of
|
# This helper simplifies passing file access modes or options regardless of
|
||||||
# whether the :encoding feature is enabled. Only the access specifier itself
|
# whether the :encoding feature is enabled. Only the access specifier itself
|
||||||
# will be returned if :encoding is not enabled. Otherwise, the full mode
|
# will be returned if :encoding is not enabled. Otherwise, the full mode
|
||||||
# string or option will be returned (i.e. the helper is a no-op).
|
# string or option will be returned (i.e. the helper is a no-op).
|
||||||
def options_or_mode(oom)
|
def options_or_mode(oom)
|
||||||
return fmode(oom) if oom.kind_of? String
|
return fmode(oom) if oom.kind_of? String
|
||||||
|
|
||||||
if FeatureGuard.enabled? :encoding
|
if FeatureGuard.enabled? :encoding
|
||||||
|
@ -109,5 +108,4 @@ class Object
|
||||||
else
|
else
|
||||||
fmode(oom[:mode] || "r:utf-8")
|
fmode(oom[:mode] || "r:utf-8")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
class Object
|
def mock_to_path(path)
|
||||||
def mock_to_path(path)
|
|
||||||
# Cannot use our Object#mock here since it conflicts with RSpec
|
# Cannot use our Object#mock here since it conflicts with RSpec
|
||||||
obj = MockObject.new('path')
|
obj = MockObject.new('path')
|
||||||
obj.should_receive(:to_path).and_return(path)
|
obj.should_receive(:to_path).and_return(path)
|
||||||
obj
|
obj
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
require 'mspec/guards/platform'
|
require 'mspec/guards/platform'
|
||||||
|
|
||||||
class Object
|
def nan_value
|
||||||
def nan_value
|
|
||||||
0/0.0
|
0/0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
def infinity_value
|
def infinity_value
|
||||||
1/0.0
|
1/0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
def bignum_value(plus=0)
|
def bignum_value(plus=0)
|
||||||
0x8000_0000_0000_0000 + plus
|
0x8000_0000_0000_0000 + plus
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is a bit hairy, but we need to be able to write specs that cover the
|
# This is a bit hairy, but we need to be able to write specs that cover the
|
||||||
# boundary between Fixnum and Bignum for operations like Fixnum#<<. Since
|
# boundary between Fixnum and Bignum for operations like Fixnum#<<. Since
|
||||||
# this boundary is implementation-dependent, we use these helpers to write
|
# this boundary is implementation-dependent, we use these helpers to write
|
||||||
# specs based on the relationship between values rather than specific
|
# specs based on the relationship between values rather than specific
|
||||||
# values.
|
# values.
|
||||||
if PlatformGuard.standard? or PlatformGuard.implementation? :topaz
|
if PlatformGuard.standard? or PlatformGuard.implementation? :topaz
|
||||||
if PlatformGuard.wordsize? 32
|
if PlatformGuard.wordsize? 32
|
||||||
def fixnum_max
|
def fixnum_max
|
||||||
(2**30) - 1
|
(2**30) - 1
|
||||||
|
@ -36,7 +35,7 @@ class Object
|
||||||
-(2**62)
|
-(2**62)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif PlatformGuard.implementation? :opal
|
elsif PlatformGuard.implementation? :opal
|
||||||
def fixnum_max
|
def fixnum_max
|
||||||
Integer::MAX
|
Integer::MAX
|
||||||
end
|
end
|
||||||
|
@ -44,7 +43,7 @@ class Object
|
||||||
def fixnum_min
|
def fixnum_min
|
||||||
Integer::MIN
|
Integer::MIN
|
||||||
end
|
end
|
||||||
elsif PlatformGuard.implementation? :rubinius
|
elsif PlatformGuard.implementation? :rubinius
|
||||||
def fixnum_max
|
def fixnum_max
|
||||||
Fixnum::MAX
|
Fixnum::MAX
|
||||||
end
|
end
|
||||||
|
@ -52,7 +51,7 @@ class Object
|
||||||
def fixnum_min
|
def fixnum_min
|
||||||
Fixnum::MIN
|
Fixnum::MIN
|
||||||
end
|
end
|
||||||
elsif PlatformGuard.implementation?(:jruby) || PlatformGuard.implementation?(:truffleruby)
|
elsif PlatformGuard.implementation?(:jruby) || PlatformGuard.implementation?(:truffleruby)
|
||||||
def fixnum_max
|
def fixnum_max
|
||||||
9223372036854775807
|
9223372036854775807
|
||||||
end
|
end
|
||||||
|
@ -60,7 +59,7 @@ class Object
|
||||||
def fixnum_min
|
def fixnum_min
|
||||||
-9223372036854775808
|
-9223372036854775808
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
def fixnum_max
|
def fixnum_max
|
||||||
raise "unknown implementation for fixnum_max() helper"
|
raise "unknown implementation for fixnum_max() helper"
|
||||||
end
|
end
|
||||||
|
@ -68,5 +67,4 @@ class Object
|
||||||
def fixnum_min
|
def fixnum_min
|
||||||
raise "unknown implementation for fixnum_min() helper"
|
raise "unknown implementation for fixnum_min() helper"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'mspec/utils/ruby_name'
|
|
||||||
require 'mspec/guards/platform'
|
require 'mspec/guards/platform'
|
||||||
require 'mspec/helpers/tmp'
|
require 'mspec/helpers/tmp'
|
||||||
|
|
||||||
|
@ -46,8 +45,8 @@ require 'mspec/helpers/tmp'
|
||||||
# constructed as follows:
|
# constructed as follows:
|
||||||
#
|
#
|
||||||
# 1. the value of ENV['RUBY_EXE']
|
# 1. the value of ENV['RUBY_EXE']
|
||||||
# 2. an explicit value based on RUBY_NAME
|
# 2. an explicit value based on RUBY_ENGINE
|
||||||
# 3. cwd/(RUBY_NAME + $(EXEEXT) || $(exeext) || '')
|
# 3. cwd/(RUBY_ENGINE + $(EXEEXT) || $(exeext) || '')
|
||||||
# 4. $(bindir)/$(RUBY_INSTALL_NAME)
|
# 4. $(bindir)/$(RUBY_INSTALL_NAME)
|
||||||
#
|
#
|
||||||
# The value will only be used if the file exists and is executable.
|
# The value will only be used if the file exists and is executable.
|
||||||
|
@ -64,8 +63,7 @@ require 'mspec/helpers/tmp'
|
||||||
# 2. Running the specs while developing an alternative
|
# 2. Running the specs while developing an alternative
|
||||||
# Ruby implementation. This explicitly names the
|
# Ruby implementation. This explicitly names the
|
||||||
# executable in the development directory based on
|
# executable in the development directory based on
|
||||||
# the value of RUBY_NAME, which is probably initialized
|
# the value of RUBY_ENGINE.
|
||||||
# from the value of RUBY_ENGINE.
|
|
||||||
# 3. Running the specs within the source directory for
|
# 3. Running the specs within the source directory for
|
||||||
# some implementation. (E.g. a local build directory.)
|
# some implementation. (E.g. a local build directory.)
|
||||||
# 4. Running the specs against some installed Ruby
|
# 4. Running the specs against some installed Ruby
|
||||||
|
@ -76,13 +74,12 @@ require 'mspec/helpers/tmp'
|
||||||
# will be appended to RUBY_EXE so that the interpreter
|
# will be appended to RUBY_EXE so that the interpreter
|
||||||
# is always called with those flags.
|
# is always called with those flags.
|
||||||
|
|
||||||
class Object
|
def ruby_exe_options(option)
|
||||||
def ruby_exe_options(option)
|
|
||||||
case option
|
case option
|
||||||
when :env
|
when :env
|
||||||
ENV['RUBY_EXE']
|
ENV['RUBY_EXE']
|
||||||
when :engine
|
when :engine
|
||||||
case RUBY_NAME
|
case RUBY_ENGINE
|
||||||
when 'rbx'
|
when 'rbx'
|
||||||
"bin/rbx"
|
"bin/rbx"
|
||||||
when 'jruby'
|
when 'jruby'
|
||||||
|
@ -96,7 +93,7 @@ class Object
|
||||||
end
|
end
|
||||||
when :name
|
when :name
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
||||||
File.join(".", bin)
|
File.join(".", bin)
|
||||||
when :install_name
|
when :install_name
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
@ -104,9 +101,9 @@ class Object
|
||||||
bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
||||||
File.join(RbConfig::CONFIG['bindir'], bin)
|
File.join(RbConfig::CONFIG['bindir'], bin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_ruby_exe
|
def resolve_ruby_exe
|
||||||
[:env, :engine, :name, :install_name].each do |option|
|
[:env, :engine, :name, :install_name].each do |option|
|
||||||
next unless exe = ruby_exe_options(option)
|
next unless exe = ruby_exe_options(option)
|
||||||
|
|
||||||
|
@ -122,9 +119,9 @@ class Object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
raise Exception, "Unable to find a suitable ruby executable."
|
raise Exception, "Unable to find a suitable ruby executable."
|
||||||
end
|
end
|
||||||
|
|
||||||
def ruby_exe(code, opts = {})
|
def ruby_exe(code, opts = {})
|
||||||
if opts[:dir]
|
if opts[:dir]
|
||||||
raise "ruby_exe(..., dir: dir) is no longer supported, use Dir.chdir"
|
raise "ruby_exe(..., dir: dir) is no longer supported, use Dir.chdir"
|
||||||
end
|
end
|
||||||
|
@ -156,9 +153,9 @@ class Object
|
||||||
end
|
end
|
||||||
File.delete tmpfile if tmpfile
|
File.delete tmpfile if tmpfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ruby_cmd(code, opts = {})
|
def ruby_cmd(code, opts = {})
|
||||||
body = code
|
body = code
|
||||||
|
|
||||||
if opts[:escape]
|
if opts[:escape]
|
||||||
|
@ -170,9 +167,8 @@ class Object
|
||||||
end
|
end
|
||||||
|
|
||||||
[RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
|
[RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
|
unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
|
||||||
RUBY_EXE = resolve_ruby_exe
|
RUBY_EXE = resolve_ruby_exe
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,8 +30,7 @@ all specs are cleaning up temporary files:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Object
|
def tmp(name, uniquify=true)
|
||||||
def tmp(name, uniquify=true)
|
|
||||||
Dir.mkdir SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
|
Dir.mkdir SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
|
||||||
|
|
||||||
if uniquify and !name.empty?
|
if uniquify and !name.empty?
|
||||||
|
@ -41,5 +40,4 @@ class Object
|
||||||
end
|
end
|
||||||
|
|
||||||
File.join SPEC_TEMP_DIR, name
|
File.join SPEC_TEMP_DIR, name
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
class Object
|
def suppress_warning
|
||||||
def suppress_warning
|
|
||||||
verbose = $VERBOSE
|
verbose = $VERBOSE
|
||||||
$VERBOSE = nil
|
$VERBOSE = nil
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
$VERBOSE = verbose
|
$VERBOSE = verbose
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ class HtmlFormatter < DottedFormatter
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Spec Output For #{RUBY_NAME} (#{RUBY_VERSION})</title>
|
<title>Spec Output For #{RUBY_ENGINE} (#{RUBY_VERSION})</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require 'mspec/expectations/expectations'
|
require 'mspec/expectations/expectations'
|
||||||
require 'mspec/utils/ruby_name'
|
|
||||||
require 'mspec/runner/formatters/yaml'
|
require 'mspec/runner/formatters/yaml'
|
||||||
|
|
||||||
class JUnitFormatter < YamlFormatter
|
class JUnitFormatter < YamlFormatter
|
||||||
|
@ -39,7 +38,7 @@ class JUnitFormatter < YamlFormatter
|
||||||
errors="#{errors}"
|
errors="#{errors}"
|
||||||
failures="#{failures}"
|
failures="#{failures}"
|
||||||
time="#{time}"
|
time="#{time}"
|
||||||
name="Spec Output For #{::RUBY_NAME} (#{::RUBY_VERSION})">
|
name="Spec Output For #{::RUBY_ENGINE} (#{::RUBY_VERSION})">
|
||||||
XML
|
XML
|
||||||
@tests.each do |h|
|
@tests.each do |h|
|
||||||
description = encode_for_xml h[:test].description
|
description = encode_for_xml h[:test].description
|
||||||
|
|
|
@ -200,13 +200,6 @@ class MSpecOptions
|
||||||
"Load FILE containing configuration options", &block)
|
"Load FILE containing configuration options", &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
|
||||||
on("-n", "--name", "RUBY_NAME",
|
|
||||||
"Set the value of RUBY_NAME (used to determine the implementation)") do |n|
|
|
||||||
Object.const_set :RUBY_NAME, n
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def targets
|
def targets
|
||||||
on("-t", "--target", "TARGET",
|
on("-t", "--target", "TARGET",
|
||||||
"Implementation to run the specs, where TARGET is:") do |t|
|
"Implementation to run the specs, where TARGET is:") do |t|
|
||||||
|
@ -469,7 +462,6 @@ class MSpecOptions
|
||||||
# Generated with:
|
# Generated with:
|
||||||
# puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/)
|
# puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/)
|
||||||
configure {}
|
configure {}
|
||||||
name
|
|
||||||
targets
|
targets
|
||||||
formatters
|
formatters
|
||||||
filters
|
filters
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
unless Object.const_defined?(:RUBY_NAME) and RUBY_NAME
|
|
||||||
if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE
|
|
||||||
RUBY_NAME = RUBY_ENGINE
|
|
||||||
else
|
|
||||||
require 'rbconfig'
|
|
||||||
RUBY_NAME = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -33,11 +33,6 @@ describe MSpecCI, "#options" do
|
||||||
@script.options ["-B", "cfg.mspec"]
|
@script.options ["-B", "cfg.mspec"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enables the name option" do
|
|
||||||
@options.should_receive(:name)
|
|
||||||
@script.options
|
|
||||||
end
|
|
||||||
|
|
||||||
it "enables the dry run option" do
|
it "enables the dry run option" do
|
||||||
@options.should_receive(:pretend)
|
@options.should_receive(:pretend)
|
||||||
@script.options
|
@script.options
|
||||||
|
|
|
@ -56,11 +56,6 @@ describe MSpecRun, "#options" do
|
||||||
@script.options ["-B", "cfg.mspec", one_spec]
|
@script.options ["-B", "cfg.mspec", one_spec]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enables the name option" do
|
|
||||||
@options.should_receive(:name)
|
|
||||||
@script.options @argv
|
|
||||||
end
|
|
||||||
|
|
||||||
it "enables the randomize option to runs specs in random order" do
|
it "enables the randomize option to runs specs in random order" do
|
||||||
@options.should_receive(:randomize)
|
@options.should_receive(:randomize)
|
||||||
@script.options @argv
|
@script.options @argv
|
||||||
|
|
|
@ -61,11 +61,6 @@ describe MSpecTag, "#options" do
|
||||||
@script.options ["-B", "cfg.mspec", one_spec]
|
@script.options ["-B", "cfg.mspec", one_spec]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enables the name option" do
|
|
||||||
@options.should_receive(:name)
|
|
||||||
@script.options @argv
|
|
||||||
end
|
|
||||||
|
|
||||||
it "enables the dry run option" do
|
it "enables the dry run option" do
|
||||||
@options.should_receive(:pretend)
|
@options.should_receive(:pretend)
|
||||||
@script.options @argv
|
@script.options @argv
|
||||||
|
|
|
@ -14,12 +14,12 @@ describe BugGuard, "#match? when #implementation? is 'ruby'" do
|
||||||
before :each do
|
before :each do
|
||||||
hide_deprecation_warnings
|
hide_deprecation_warnings
|
||||||
stub_const "VersionGuard::FULL_RUBY_VERSION", SpecVersion.new('1.8.6')
|
stub_const "VersionGuard::FULL_RUBY_VERSION", SpecVersion.new('1.8.6')
|
||||||
@ruby_name = Object.const_get :RUBY_NAME
|
@ruby_engine = Object.const_get :RUBY_ENGINE
|
||||||
Object.const_set :RUBY_NAME, 'ruby'
|
Object.const_set :RUBY_ENGINE, 'ruby'
|
||||||
end
|
end
|
||||||
|
|
||||||
after :each do
|
after :each do
|
||||||
Object.const_set :RUBY_NAME, @ruby_name
|
Object.const_set :RUBY_ENGINE, @ruby_engine
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when version argument is less than RUBY_VERSION" do
|
it "returns false when version argument is less than RUBY_VERSION" do
|
||||||
|
@ -76,15 +76,15 @@ describe BugGuard, "#match? when #implementation? is not 'ruby'" do
|
||||||
before :each do
|
before :each do
|
||||||
hide_deprecation_warnings
|
hide_deprecation_warnings
|
||||||
@ruby_version = Object.const_get :RUBY_VERSION
|
@ruby_version = Object.const_get :RUBY_VERSION
|
||||||
@ruby_name = Object.const_get :RUBY_NAME
|
@ruby_engine = Object.const_get :RUBY_ENGINE
|
||||||
|
|
||||||
Object.const_set :RUBY_VERSION, '1.8.6'
|
Object.const_set :RUBY_VERSION, '1.8.6'
|
||||||
Object.const_set :RUBY_NAME, 'jruby'
|
Object.const_set :RUBY_ENGINE, 'jruby'
|
||||||
end
|
end
|
||||||
|
|
||||||
after :each do
|
after :each do
|
||||||
Object.const_set :RUBY_VERSION, @ruby_version
|
Object.const_set :RUBY_VERSION, @ruby_version
|
||||||
Object.const_set :RUBY_NAME, @ruby_name
|
Object.const_set :RUBY_ENGINE, @ruby_engine
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when version argument is less than RUBY_VERSION" do
|
it "returns false when version argument is less than RUBY_VERSION" do
|
||||||
|
|
|
@ -120,56 +120,56 @@ describe PlatformGuard, ".implementation?" do
|
||||||
end
|
end
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@ruby_name = Object.const_get :RUBY_NAME
|
@ruby_engine = Object.const_get :RUBY_ENGINE
|
||||||
end
|
end
|
||||||
|
|
||||||
after :each do
|
after :each do
|
||||||
Object.const_set :RUBY_NAME, @ruby_name
|
Object.const_set :RUBY_ENGINE, @ruby_engine
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :ruby and RUBY_NAME == 'ruby'" do
|
it "returns true if passed :ruby and RUBY_ENGINE == 'ruby'" do
|
||||||
Object.const_set :RUBY_NAME, 'ruby'
|
Object.const_set :RUBY_ENGINE, 'ruby'
|
||||||
PlatformGuard.implementation?(:ruby).should == true
|
PlatformGuard.implementation?(:ruby).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :rubinius and RUBY_NAME == 'rbx'" do
|
it "returns true if passed :rubinius and RUBY_ENGINE == 'rbx'" do
|
||||||
Object.const_set :RUBY_NAME, 'rbx'
|
Object.const_set :RUBY_ENGINE, 'rbx'
|
||||||
PlatformGuard.implementation?(:rubinius).should == true
|
PlatformGuard.implementation?(:rubinius).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :jruby and RUBY_NAME == 'jruby'" do
|
it "returns true if passed :jruby and RUBY_ENGINE == 'jruby'" do
|
||||||
Object.const_set :RUBY_NAME, 'jruby'
|
Object.const_set :RUBY_ENGINE, 'jruby'
|
||||||
PlatformGuard.implementation?(:jruby).should == true
|
PlatformGuard.implementation?(:jruby).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :ironruby and RUBY_NAME == 'ironruby'" do
|
it "returns true if passed :ironruby and RUBY_ENGINE == 'ironruby'" do
|
||||||
Object.const_set :RUBY_NAME, 'ironruby'
|
Object.const_set :RUBY_ENGINE, 'ironruby'
|
||||||
PlatformGuard.implementation?(:ironruby).should == true
|
PlatformGuard.implementation?(:ironruby).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :maglev and RUBY_NAME == 'maglev'" do
|
it "returns true if passed :maglev and RUBY_ENGINE == 'maglev'" do
|
||||||
Object.const_set :RUBY_NAME, 'maglev'
|
Object.const_set :RUBY_ENGINE, 'maglev'
|
||||||
PlatformGuard.implementation?(:maglev).should == true
|
PlatformGuard.implementation?(:maglev).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :topaz and RUBY_NAME == 'topaz'" do
|
it "returns true if passed :topaz and RUBY_ENGINE == 'topaz'" do
|
||||||
Object.const_set :RUBY_NAME, 'topaz'
|
Object.const_set :RUBY_ENGINE, 'topaz'
|
||||||
PlatformGuard.implementation?(:topaz).should == true
|
PlatformGuard.implementation?(:topaz).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if passed :ruby and RUBY_NAME matches /^ruby/" do
|
it "returns true if passed :ruby and RUBY_ENGINE matches /^ruby/" do
|
||||||
Object.const_set :RUBY_NAME, 'ruby'
|
Object.const_set :RUBY_ENGINE, 'ruby'
|
||||||
PlatformGuard.implementation?(:ruby).should == true
|
PlatformGuard.implementation?(:ruby).should == true
|
||||||
|
|
||||||
Object.const_set :RUBY_NAME, 'ruby1.8'
|
Object.const_set :RUBY_ENGINE, 'ruby1.8'
|
||||||
PlatformGuard.implementation?(:ruby).should == true
|
PlatformGuard.implementation?(:ruby).should == true
|
||||||
|
|
||||||
Object.const_set :RUBY_NAME, 'ruby1.9'
|
Object.const_set :RUBY_ENGINE, 'ruby1.9'
|
||||||
PlatformGuard.implementation?(:ruby).should == true
|
PlatformGuard.implementation?(:ruby).should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error when passed an unrecognized name" do
|
it "raises an error when passed an unrecognized name" do
|
||||||
Object.const_set :RUBY_NAME, 'ruby'
|
Object.const_set :RUBY_ENGINE, 'ruby'
|
||||||
lambda {
|
lambda {
|
||||||
PlatformGuard.implementation?(:python)
|
PlatformGuard.implementation?(:python)
|
||||||
}.should raise_error(/unknown implementation/)
|
}.should raise_error(/unknown implementation/)
|
||||||
|
|
|
@ -5,15 +5,15 @@ describe Object, "#not_supported_on" do
|
||||||
before :all do
|
before :all do
|
||||||
@verbose = $VERBOSE
|
@verbose = $VERBOSE
|
||||||
$VERBOSE = nil
|
$VERBOSE = nil
|
||||||
@ruby_name = Object.const_get :RUBY_NAME if Object.const_defined? :RUBY_NAME
|
@ruby_engine = Object.const_get :RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
|
||||||
end
|
end
|
||||||
|
|
||||||
after :all do
|
after :all do
|
||||||
$VERBOSE = @verbose
|
$VERBOSE = @verbose
|
||||||
if @ruby_name
|
if @ruby_engine
|
||||||
Object.const_set :RUBY_NAME, @ruby_name
|
Object.const_set :RUBY_ENGINE, @ruby_engine
|
||||||
else
|
else
|
||||||
Object.send :remove_const, :RUBY_NAME
|
Object.send :remove_const, :RUBY_ENGINE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ describe Object, "#not_supported_on" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an Exception when passed :ruby" do
|
it "raises an Exception when passed :ruby" do
|
||||||
Object.const_set :RUBY_NAME, "jruby"
|
Object.const_set :RUBY_ENGINE, "jruby"
|
||||||
lambda {
|
lambda {
|
||||||
not_supported_on(:ruby) { ScratchPad.record :yield }
|
not_supported_on(:ruby) { ScratchPad.record :yield }
|
||||||
}.should raise_error(Exception)
|
}.should raise_error(Exception)
|
||||||
|
@ -30,19 +30,19 @@ describe Object, "#not_supported_on" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not yield when #implementation? returns true" do
|
it "does not yield when #implementation? returns true" do
|
||||||
Object.const_set :RUBY_NAME, "jruby"
|
Object.const_set :RUBY_ENGINE, "jruby"
|
||||||
not_supported_on(:jruby) { ScratchPad.record :yield }
|
not_supported_on(:jruby) { ScratchPad.record :yield }
|
||||||
ScratchPad.recorded.should_not == :yield
|
ScratchPad.recorded.should_not == :yield
|
||||||
end
|
end
|
||||||
|
|
||||||
it "yields when #standard? returns true" do
|
it "yields when #standard? returns true" do
|
||||||
Object.const_set :RUBY_NAME, "ruby"
|
Object.const_set :RUBY_ENGINE, "ruby"
|
||||||
not_supported_on(:rubinius) { ScratchPad.record :yield }
|
not_supported_on(:rubinius) { ScratchPad.record :yield }
|
||||||
ScratchPad.recorded.should == :yield
|
ScratchPad.recorded.should == :yield
|
||||||
end
|
end
|
||||||
|
|
||||||
it "yields when #implementation? returns false" do
|
it "yields when #implementation? returns false" do
|
||||||
Object.const_set :RUBY_NAME, "jruby"
|
Object.const_set :RUBY_ENGINE, "jruby"
|
||||||
not_supported_on(:rubinius) { ScratchPad.record :yield }
|
not_supported_on(:rubinius) { ScratchPad.record :yield }
|
||||||
ScratchPad.recorded.should == :yield
|
ScratchPad.recorded.should == :yield
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,10 @@ require 'mspec/helpers'
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
class RubyExeSpecs
|
class RubyExeSpecs
|
||||||
|
public :ruby_exe_options
|
||||||
|
public :resolve_ruby_exe
|
||||||
|
public :ruby_cmd
|
||||||
|
public :ruby_exe
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#ruby_exe_options" do
|
describe "#ruby_exe_options" do
|
||||||
|
@ -11,14 +15,14 @@ describe "#ruby_exe_options" do
|
||||||
@verbose = $VERBOSE
|
@verbose = $VERBOSE
|
||||||
$VERBOSE = nil
|
$VERBOSE = nil
|
||||||
|
|
||||||
@ruby_name = Object.const_get :RUBY_NAME
|
@ruby_engine = Object.const_get :RUBY_ENGINE
|
||||||
@ruby_exe_env = ENV['RUBY_EXE']
|
@ruby_exe_env = ENV['RUBY_EXE']
|
||||||
|
|
||||||
@script = RubyExeSpecs.new
|
@script = RubyExeSpecs.new
|
||||||
end
|
end
|
||||||
|
|
||||||
after :all do
|
after :all do
|
||||||
Object.const_set :RUBY_NAME, @ruby_name
|
Object.const_set :RUBY_ENGINE, @ruby_engine
|
||||||
ENV['RUBY_EXE'] = @ruby_exe_env
|
ENV['RUBY_EXE'] = @ruby_exe_env
|
||||||
$VERBOSE = @verbose
|
$VERBOSE = @verbose
|
||||||
end
|
end
|
||||||
|
@ -32,33 +36,33 @@ describe "#ruby_exe_options" do
|
||||||
@script.ruby_exe_options(:env).should == "kowabunga"
|
@script.ruby_exe_options(:env).should == "kowabunga"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 'bin/jruby' when passed :engine and RUBY_NAME is 'jruby'" do
|
it "returns 'bin/jruby' when passed :engine and RUBY_ENGINE is 'jruby'" do
|
||||||
Object.const_set :RUBY_NAME, 'jruby'
|
Object.const_set :RUBY_ENGINE, 'jruby'
|
||||||
@script.ruby_exe_options(:engine).should == 'bin/jruby'
|
@script.ruby_exe_options(:engine).should == 'bin/jruby'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 'bin/rbx' when passed :engine, RUBY_NAME is 'rbx'" do
|
it "returns 'bin/rbx' when passed :engine, RUBY_ENGINE is 'rbx'" do
|
||||||
Object.const_set :RUBY_NAME, 'rbx'
|
Object.const_set :RUBY_ENGINE, 'rbx'
|
||||||
@script.ruby_exe_options(:engine).should == 'bin/rbx'
|
@script.ruby_exe_options(:engine).should == 'bin/rbx'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 'ir' when passed :engine and RUBY_NAME is 'ironruby'" do
|
it "returns 'ir' when passed :engine and RUBY_ENGINE is 'ironruby'" do
|
||||||
Object.const_set :RUBY_NAME, 'ironruby'
|
Object.const_set :RUBY_ENGINE, 'ironruby'
|
||||||
@script.ruby_exe_options(:engine).should == 'ir'
|
@script.ruby_exe_options(:engine).should == 'ir'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 'maglev-ruby' when passed :engine and RUBY_NAME is 'maglev'" do
|
it "returns 'maglev-ruby' when passed :engine and RUBY_ENGINE is 'maglev'" do
|
||||||
Object.const_set :RUBY_NAME, 'maglev'
|
Object.const_set :RUBY_ENGINE, 'maglev'
|
||||||
@script.ruby_exe_options(:engine).should == 'maglev-ruby'
|
@script.ruby_exe_options(:engine).should == 'maglev-ruby'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 'topaz' when passed :engine and RUBY_NAME is 'topaz'" do
|
it "returns 'topaz' when passed :engine and RUBY_ENGINE is 'topaz'" do
|
||||||
Object.const_set :RUBY_NAME, 'topaz'
|
Object.const_set :RUBY_ENGINE, 'topaz'
|
||||||
@script.ruby_exe_options(:engine).should == 'topaz'
|
@script.ruby_exe_options(:engine).should == 'topaz'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns RUBY_NAME + $(EXEEXT) when passed :name" do
|
it "returns RUBY_ENGINE + $(EXEEXT) when passed :name" do
|
||||||
bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
|
||||||
name = File.join ".", bin
|
name = File.join ".", bin
|
||||||
@script.ruby_exe_options(:name).should == name
|
@script.ruby_exe_options(:name).should == name
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require File.dirname(__FILE__) + '/../../spec_helper'
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||||
require 'mspec/utils/ruby_name'
|
|
||||||
require 'mspec/guards/guard'
|
require 'mspec/guards/guard'
|
||||||
require 'mspec/runner/formatters/html'
|
require 'mspec/runner/formatters/html'
|
||||||
require 'mspec/runner/mspec'
|
require 'mspec/runner/mspec'
|
||||||
|
@ -32,14 +31,14 @@ describe HtmlFormatter, "#start" do
|
||||||
|
|
||||||
it "prints the HTML head" do
|
it "prints the HTML head" do
|
||||||
@formatter.start
|
@formatter.start
|
||||||
ruby_name = RUBY_NAME
|
ruby_engine = RUBY_ENGINE
|
||||||
ruby_name.should =~ /^#{ruby_name}/
|
ruby_engine.should =~ /^#{ruby_engine}/
|
||||||
@out.should ==
|
@out.should ==
|
||||||
%[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
%[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Spec Output For #{ruby_name} (#{RUBY_VERSION})</title>
|
<title>Spec Output For #{ruby_engine} (#{RUBY_VERSION})</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
|
@ -507,30 +507,6 @@ describe "The --prefix STR option" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "The -n, --name RUBY_NAME option" do
|
|
||||||
before :each do
|
|
||||||
@verbose, $VERBOSE = $VERBOSE, nil
|
|
||||||
@options, @config = new_option
|
|
||||||
end
|
|
||||||
|
|
||||||
after :each do
|
|
||||||
$VERBOSE = @verbose
|
|
||||||
end
|
|
||||||
|
|
||||||
it "is enabled with #name" do
|
|
||||||
@options.should_receive(:on).with("-n", "--name", "RUBY_NAME",
|
|
||||||
an_instance_of(String))
|
|
||||||
@options.name
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sets RUBY_NAME when invoked" do
|
|
||||||
Object.should_receive(:const_set).with(:RUBY_NAME, "name").twice
|
|
||||||
@options.name
|
|
||||||
@options.parse ["-n", "name"]
|
|
||||||
@options.parse ["--name", "name"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "The -t, --target TARGET option" do
|
describe "The -t, --target TARGET option" do
|
||||||
before :each do
|
before :each do
|
||||||
@options, @config = new_option
|
@options, @config = new_option
|
||||||
|
|
|
@ -24,6 +24,9 @@ raise RUBYSPEC_REPO unless Dir.exist?(RUBYSPEC_REPO)
|
||||||
|
|
||||||
NOW = Time.now
|
NOW = Time.now
|
||||||
|
|
||||||
|
BRIGHT_YELLOW = "\e[33;1m"
|
||||||
|
RESET = "\e[0m"
|
||||||
|
|
||||||
class RubyImplementation
|
class RubyImplementation
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
|
@ -110,7 +113,7 @@ def rebase_commits(impl)
|
||||||
|
|
||||||
rebased = impl.rebased_branch
|
rebased = impl.rebased_branch
|
||||||
if branch?(rebased)
|
if branch?(rebased)
|
||||||
puts "#{rebased} already exists, assuming it correct"
|
puts "#{BRIGHT_YELLOW}#{rebased} already exists, assuming it correct#{RESET}"
|
||||||
sh "git", "checkout", rebased
|
sh "git", "checkout", rebased
|
||||||
else
|
else
|
||||||
sh "git", "checkout", impl.name
|
sh "git", "checkout", impl.name
|
||||||
|
@ -118,7 +121,7 @@ def rebase_commits(impl)
|
||||||
if ENV["LAST_MERGE"]
|
if ENV["LAST_MERGE"]
|
||||||
last_merge = `git log -n 1 --format='%H %ct' #{ENV["LAST_MERGE"]}`
|
last_merge = `git log -n 1 --format='%H %ct' #{ENV["LAST_MERGE"]}`
|
||||||
else
|
else
|
||||||
last_merge = `git log --grep='#{impl.last_merge_message}' -n 1 --format='%H %ct'`
|
last_merge = `git log --grep='^#{impl.last_merge_message}' -n 1 --format='%H %ct'`
|
||||||
end
|
end
|
||||||
last_merge, commit_timestamp = last_merge.chomp.split(' ')
|
last_merge, commit_timestamp = last_merge.chomp.split(' ')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue