summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 15:56:09 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 15:56:09 +0000
commit49a864ad902c7e819f2464f1001e9719a9af6cb5 (patch)
tree3b084371c3dfc8cb6eda885094b9470014c8e48b
parent3efe410dd0812a3781b9f75a52d67a632009b2d2 (diff)
Update to ruby/mspec@5bd9409
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--spec/mspec/.travis.yml16
-rw-r--r--spec/mspec/Gemfile4
-rw-r--r--spec/mspec/Gemfile.lock8
-rw-r--r--spec/mspec/README.md3
-rw-r--r--spec/mspec/lib/mspec/matchers/raise_error.rb10
-rw-r--r--spec/mspec/lib/mspec/mocks/mock.rb15
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/multi.rb3
-rw-r--r--spec/mspec/lib/mspec/runner/mspec.rb6
-rw-r--r--spec/mspec/lib/mspec/utils/script.rb4
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb19
-rw-r--r--spec/mspec/mspec.gemspec40
-rw-r--r--spec/mspec/spec/commands/mkspec_spec.rb8
-rw-r--r--spec/mspec/spec/commands/mspec_ci_spec.rb28
-rw-r--r--spec/mspec/spec/guards/guard_spec.rb7
-rw-r--r--spec/mspec/spec/guards/support_spec.rb23
-rw-r--r--spec/mspec/spec/helpers/io_spec.rb6
-rw-r--r--spec/mspec/spec/matchers/be_kind_of_spec.rb4
-rw-r--r--spec/mspec/spec/matchers/have_class_variable_spec.rb23
-rw-r--r--spec/mspec/spec/matchers/have_instance_variable_spec.rb23
-rw-r--r--spec/mspec/spec/runner/context_spec.rb2
-rw-r--r--spec/mspec/spec/runner/mspec_spec.rb4
-rw-r--r--spec/mspec/spec/spec_helper.rb2
-rw-r--r--spec/mspec/tool/sync/sync-rubyspec.rb21
23 files changed, 121 insertions, 158 deletions
diff --git a/spec/mspec/.travis.yml b/spec/mspec/.travis.yml
index 26a21e3aeb..5b6795c2b2 100644
--- a/spec/mspec/.travis.yml
+++ b/spec/mspec/.travis.yml
@@ -2,8 +2,14 @@ sudo: false
language: ruby
script:
- bundle exec rspec
-rvm:
- - 2.2.7
- - 2.3.4
- - 2.4.1
- - ruby-head
+matrix:
+ include:
+ - rvm: 2.2.7
+ - rvm: 2.3.4
+ - rvm: 2.4.1
+ - rvm: ruby-head
+ - jdk: oraclejdk8
+ install:
+ - curl -L https://github.com/graalvm/truffleruby/releases/download/vm-enterprise-0.27/truffleruby-testing-0.27.tar.gz | tar xz
+ - source truffleruby/setup_env
+ - bundle install
diff --git a/spec/mspec/Gemfile b/spec/mspec/Gemfile
index 82a7d1678b..3dc3c4145b 100644
--- a/spec/mspec/Gemfile
+++ b/spec/mspec/Gemfile
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
-# Specify your gem's dependencies in mspec.gemspec
-gemspec
+gem "rake", "~> 10.0"
+gem "rspec", "~> 2.14.1"
diff --git a/spec/mspec/Gemfile.lock b/spec/mspec/Gemfile.lock
index ddd7fde498..d07c04638b 100644
--- a/spec/mspec/Gemfile.lock
+++ b/spec/mspec/Gemfile.lock
@@ -1,8 +1,3 @@
-PATH
- remote: .
- specs:
- mspec (1.8.0)
-
GEM
remote: https://rubygems.org/
specs:
@@ -22,9 +17,8 @@ PLATFORMS
ruby
DEPENDENCIES
- mspec!
rake (~> 10.0)
rspec (~> 2.14.1)
BUNDLED WITH
- 1.10.2
+ 1.14.5
diff --git a/spec/mspec/README.md b/spec/mspec/README.md
index 8420fc1fce..18ca8fcdd3 100644
--- a/spec/mspec/README.md
+++ b/spec/mspec/README.md
@@ -33,6 +33,9 @@ specs in a manner compatible with multiple Ruby implementations.
configuration facility with a default project file and user-specific
overrides.
+## Requirements
+
+MSpec requires Ruby 2.2 or more recent.
## Bundler
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb
index d128ca03ea..28c7a5ea2f 100644
--- a/spec/mspec/lib/mspec/matchers/raise_error.rb
+++ b/spec/mspec/lib/mspec/matchers/raise_error.rb
@@ -5,16 +5,18 @@ class RaiseErrorMatcher
@exception = exception
@message = message
@block = block
+ @actual = nil
end
def matches?(proc)
@result = proc.call
return false
- rescue Exception => @actual
- if matching_exception?(@actual)
+ rescue Exception => actual
+ @actual = actual
+ if matching_exception?(actual)
return true
else
- raise @actual
+ raise actual
end
end
@@ -54,7 +56,7 @@ class RaiseErrorMatcher
def failure_message
message = ["Expected #{format_expected_exception}"]
- if @actual then
+ if @actual
message << "but got #{format_exception(@actual)}"
else
message << "but no exception was raised (#{@result.pretty_inspect.chomp} was returned)"
diff --git a/spec/mspec/lib/mspec/mocks/mock.rb b/spec/mspec/lib/mspec/mocks/mock.rb
index 9fc72b5631..f833cba371 100644
--- a/spec/mspec/lib/mspec/mocks/mock.rb
+++ b/spec/mspec/lib/mspec/mocks/mock.rb
@@ -1,4 +1,5 @@
require 'mspec/expectations/expectations'
+require 'mspec/helpers/warning'
module Mock
def self.reset
@@ -57,10 +58,12 @@ module Mock
meta.__send__ :alias_method, key.first, sym
end
- meta.class_eval {
- define_method(sym) do |*args, &block|
- Mock.verify_call self, sym, *args, &block
- end
+ suppress_warning {
+ meta.class_eval {
+ define_method(sym) do |*args, &block|
+ Mock.verify_call self, sym, *args, &block
+ end
+ }
}
proxy = MockProxy.new type
@@ -179,7 +182,9 @@ module Mock
meta = obj.singleton_class
if mock_respond_to? obj, replaced, true
- meta.__send__ :alias_method, sym, replaced
+ suppress_warning do
+ meta.__send__ :alias_method, sym, replaced
+ end
meta.__send__ :remove_method, replaced
else
meta.__send__ :remove_method, sym
diff --git a/spec/mspec/lib/mspec/runner/formatters/multi.rb b/spec/mspec/lib/mspec/runner/formatters/multi.rb
index bcc5411e6f..f69055025f 100644
--- a/spec/mspec/lib/mspec/runner/formatters/multi.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/multi.rb
@@ -1,5 +1,4 @@
require 'mspec/runner/formatters/spinner'
-require 'yaml'
class MultiFormatter < SpinnerFormatter
def initialize(out=nil)
@@ -10,6 +9,8 @@ class MultiFormatter < SpinnerFormatter
end
def aggregate_results(files)
+ require 'yaml'
+
@timer.finish
@exceptions = []
diff --git a/spec/mspec/lib/mspec/runner/mspec.rb b/spec/mspec/lib/mspec/runner/mspec.rb
index 8f9c7a602f..d47657326b 100644
--- a/spec/mspec/lib/mspec/runner/mspec.rb
+++ b/spec/mspec/lib/mspec/runner/mspec.rb
@@ -2,6 +2,9 @@ require 'mspec/runner/context'
require 'mspec/runner/exception'
require 'mspec/runner/tag'
+module MSpec
+end
+
class MSpecEnv
include MSpec
end
@@ -399,4 +402,7 @@ module MSpec
file = tags_file
File.delete file if File.exist? file
end
+
+ # Initialize @env
+ setup_env
end
diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb
index 1c7d0aeb52..0c8922c4a8 100644
--- a/spec/mspec/lib/mspec/utils/script.rb
+++ b/spec/mspec/lib/mspec/utils/script.rb
@@ -38,6 +38,10 @@ class MSpecScript
end
def initialize
+ if RUBY_VERSION < '2.2'
+ abort "MSpec needs Ruby 2.2 or more recent"
+ end
+
config[:formatter] = nil
config[:includes] = []
config[:excludes] = []
diff --git a/spec/mspec/lib/mspec/utils/warnings.rb b/spec/mspec/lib/mspec/utils/warnings.rb
index 74c7f88a52..ef5e5c692c 100644
--- a/spec/mspec/lib/mspec/utils/warnings.rb
+++ b/spec/mspec/lib/mspec/utils/warnings.rb
@@ -4,6 +4,7 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
ruby_version_is "2.4"..."2.5" do
# Kernel#warn does not delegate to Warning.warn in 2.4
module Kernel
+ remove_method :warn
def warn(*messages)
return if $VERBOSE == nil or messages.empty?
msg = messages.join("\n")
@@ -16,6 +17,24 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
def Warning.warn(message)
case message
+ # $VERBOSE = true warnings
+ when /possibly useless use of (<|<=|==|>=|>|\+|-) in void context/
+ when /assigned but unused variable/
+ when /method redefined/
+ when /previous definition of/
+ when /instance variable @.+ not initialized/
+ when /statement not reached/
+ when /shadowing outer local variable/
+ when /setting Encoding.default_(in|ex)ternal/
+ when /unknown (un)?pack directive/
+ when /(un)?trust(ed\?)? is deprecated/
+ when /\.exists\? is a deprecated name/
+ when /Float .+ out of range/
+ when /passing a block to String#(bytes|chars|codepoints|lines) is deprecated/
+ when /core\/string\/modulo_spec\.rb:\d+: warning: too many arguments for format string/
+ when /regexp\/shared\/new_ascii(_8bit)?\.rb:\d+: warning: Unknown escape .+ is ignored/
+
+ # $VERBOSE = false warnings
when /constant ::(Fixnum|Bignum) is deprecated/
when /\/(argf|io|stringio)\/.+(ARGF|IO)#(lines|chars|bytes|codepoints) is deprecated/
when /Thread\.exclusive is deprecated.+\n.+thread\/exclusive_spec\.rb/
diff --git a/spec/mspec/mspec.gemspec b/spec/mspec/mspec.gemspec
deleted file mode 100644
index 428067dfd3..0000000000
--- a/spec/mspec/mspec.gemspec
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- encoding: utf-8 -*-
-$:.unshift File.expand_path('../lib', __FILE__)
-require 'mspec/version'
-
-Gem::Specification.new do |gem|
- gem.name = "mspec"
- gem.version = MSpec::VERSION.to_s
- gem.authors = ["Brian Shirai"]
- gem.email = ["bshirai@engineyard.com"]
- gem.homepage = "http://rubyspec.org"
-
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) unless File.extname(f) == ".bat" }.compact
- gem.files = `git ls-files`.split("\n")
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- gem.require_paths = ["lib"]
- gem.description = <<-EOD
-MSpec is a specialized framework for RubySpec.
- EOD
- gem.summary = <<-EOS
-MSpec is a specialized framework that is syntax-compatible
-with RSpec for basic things like describe, it blocks and
-before, after actions.
-
-MSpec contains additional features that assist in writing
-the RubySpecs used by multiple Ruby implementations. Also,
-MSpec attempts to use the simplest Ruby language features
-so that beginning Ruby implementations can run it.
- EOS
- gem.has_rdoc = true
- gem.extra_rdoc_files = %w[ README.md LICENSE ]
- gem.rubygems_version = %q{1.3.5}
- gem.rubyforge_project = 'http://rubyforge.org/projects/mspec'
-
- gem.rdoc_options << '--title' << 'MSpec Gem' <<
- '--main' << 'README.md' <<
- '--line-numbers'
-
- gem.add_development_dependency "rake", "~> 10.0"
- gem.add_development_dependency "rspec", "~> 2.14.1"
-end
diff --git a/spec/mspec/spec/commands/mkspec_spec.rb b/spec/mspec/spec/commands/mkspec_spec.rb
index ab3410af50..14c363f286 100644
--- a/spec/mspec/spec/commands/mkspec_spec.rb
+++ b/spec/mspec/spec/commands/mkspec_spec.rb
@@ -38,7 +38,7 @@ describe "The -b, --base DIR option" do
@options.stub(:on)
@options.should_receive(:on).with("-b", "--base", "DIR",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "sets the base directory relative to which the spec directories are created" do
@@ -62,7 +62,7 @@ describe "The -r, --require LIBRARY option" do
@options.stub(:on)
@options.should_receive(:on).with("-r", "--require", "LIBRARY",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "adds CONSTANT to the list of constants" do
@@ -86,7 +86,7 @@ describe "The -V, --version-guard VERSION option" do
@options.stub(:on)
@options.should_receive(:on).with("-V", "--version-guard", "VERSION",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "sets the version for the ruby_version_is guards to VERSION" do
@@ -119,7 +119,7 @@ describe MkSpec, "#options" do
@options.should_receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
@options.stub(:puts)
@options.stub(:exit)
- @script.options "--iunknown"
+ @script.options ["--iunknown"]
end
end
diff --git a/spec/mspec/spec/commands/mspec_ci_spec.rb b/spec/mspec/spec/commands/mspec_ci_spec.rb
index 5221363953..a90cbd8d0d 100644
--- a/spec/mspec/spec/commands/mspec_ci_spec.rb
+++ b/spec/mspec/spec/commands/mspec_ci_spec.rb
@@ -15,17 +15,17 @@ describe MSpecCI, "#options" do
it "enables the chdir option" do
@options.should_receive(:chdir)
- @script.options
+ @script.options []
end
it "enables the prefix option" do
@options.should_receive(:prefix)
- @script.options
+ @script.options []
end
it "enables the config option" do
@options.should_receive(:configure)
- @script.options
+ @script.options []
end
it "provides a custom action (block) to the config option" do
@@ -35,52 +35,52 @@ describe MSpecCI, "#options" do
it "enables the dry run option" do
@options.should_receive(:pretend)
- @script.options
+ @script.options []
end
it "enables the unguarded option" do
@options.should_receive(:unguarded)
- @script.options
+ @script.options []
end
it "enables the interrupt single specs option" do
@options.should_receive(:interrupt)
- @script.options
+ @script.options []
end
it "enables the formatter options" do
@options.should_receive(:formatters)
- @script.options
+ @script.options []
end
it "enables the verbose option" do
@options.should_receive(:verbose)
- @script.options
+ @script.options []
end
it "enables the action options" do
@options.should_receive(:actions)
- @script.options
+ @script.options []
end
it "enables the action filter options" do
@options.should_receive(:action_filters)
- @script.options
+ @script.options []
end
it "enables the version option" do
@options.should_receive(:version)
- @script.options
+ @script.options []
end
it "enables the help option" do
@options.should_receive(:help)
- @script.options
+ @script.options []
end
it "calls #custom_options" do
@script.should_receive(:custom_options).with(@options)
- @script.options
+ @script.options []
end
end
@@ -99,7 +99,7 @@ describe MSpecCI, "#run" do
@script.stub(:exit)
@script.stub(:config).and_return(@config)
@script.stub(:files).and_return(["one", "two"])
- @script.options
+ @script.options []
end
it "registers the tags patterns" do
diff --git a/spec/mspec/spec/guards/guard_spec.rb b/spec/mspec/spec/guards/guard_spec.rb
index f2828dd4ad..5c3dae4b3f 100644
--- a/spec/mspec/spec/guards/guard_spec.rb
+++ b/spec/mspec/spec/guards/guard_spec.rb
@@ -4,12 +4,7 @@ require 'rbconfig'
describe SpecGuard, ".ruby_version" do
before :each do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, "8.2.3"
- end
-
- after :each do
- Object.const_set :RUBY_VERSION, @ruby_version
+ stub_const "RUBY_VERSION", "8.2.3"
end
it "returns the full version for :full" do
diff --git a/spec/mspec/spec/guards/support_spec.rb b/spec/mspec/spec/guards/support_spec.rb
index f899ad02f6..38414abebd 100644
--- a/spec/mspec/spec/guards/support_spec.rb
+++ b/spec/mspec/spec/guards/support_spec.rb
@@ -2,27 +2,12 @@ require 'spec_helper'
require 'mspec/guards'
describe Object, "#not_supported_on" do
- before :all do
- @verbose = $VERBOSE
- $VERBOSE = nil
- @ruby_engine = Object.const_get :RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
- end
-
- after :all do
- $VERBOSE = @verbose
- if @ruby_engine
- Object.const_set :RUBY_ENGINE, @ruby_engine
- else
- Object.send :remove_const, :RUBY_ENGINE
- end
- end
-
before :each do
ScratchPad.clear
end
it "raises an Exception when passed :ruby" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
lambda {
not_supported_on(:ruby) { ScratchPad.record :yield }
}.should raise_error(Exception)
@@ -30,19 +15,19 @@ describe Object, "#not_supported_on" do
end
it "does not yield when #implementation? returns true" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
not_supported_on(:jruby) { ScratchPad.record :yield }
ScratchPad.recorded.should_not == :yield
end
it "yields when #standard? returns true" do
- Object.const_set :RUBY_ENGINE, "ruby"
+ stub_const "RUBY_ENGINE", "ruby"
not_supported_on(:rubinius) { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
it "yields when #implementation? returns false" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
not_supported_on(:rubinius) { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb
index 6dfd81ee56..3219f59947 100644
--- a/spec/mspec/spec/helpers/io_spec.rb
+++ b/spec/mspec/spec/helpers/io_spec.rb
@@ -60,9 +60,9 @@ describe Object, "#new_fd" do
rm_r @name
end
- it "returns a Fixnum that can be used to create an IO instance" do
+ it "returns a Integer that can be used to create an IO instance" do
fd = new_fd @name
- fd.should be_an_instance_of(Fixnum)
+ fd.should be_kind_of(Integer)
@io = IO.new fd, fmode('w:utf-8')
@io.sync = true
@@ -74,7 +74,7 @@ describe Object, "#new_fd" do
it "accepts an options Hash" do
FeatureGuard.stub(:enabled?).and_return(true)
fd = new_fd @name, { :mode => 'w:utf-8' }
- fd.should be_an_instance_of(Fixnum)
+ fd.should be_kind_of(Integer)
@io = IO.new fd, fmode('w:utf-8')
@io.sync = true
diff --git a/spec/mspec/spec/matchers/be_kind_of_spec.rb b/spec/mspec/spec/matchers/be_kind_of_spec.rb
index 554ae6aa82..7c4a59f7b9 100644
--- a/spec/mspec/spec/matchers/be_kind_of_spec.rb
+++ b/spec/mspec/spec/matchers/be_kind_of_spec.rb
@@ -4,8 +4,8 @@ require 'mspec/matchers'
describe BeKindOfMatcher do
it "matches when actual is a kind_of? expected" do
- BeKindOfMatcher.new(Integer).matches?(1).should == true
- BeKindOfMatcher.new(Fixnum).matches?(2).should == true
+ BeKindOfMatcher.new(Numeric).matches?(1).should == true
+ BeKindOfMatcher.new(Integer).matches?(2).should == true
BeKindOfMatcher.new(Regexp).matches?(/m/).should == true
end
diff --git a/spec/mspec/spec/matchers/have_class_variable_spec.rb b/spec/mspec/spec/matchers/have_class_variable_spec.rb
index e440050056..01ba9d0f57 100644
--- a/spec/mspec/spec/matchers/have_class_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_class_variable_spec.rb
@@ -2,13 +2,13 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-class IVarModMock; end
-
-shared_examples_for "have_class_variable, on all Ruby versions" do
- after :all do
- Object.const_set :RUBY_VERSION, @ruby_version
+class IVarModMock
+ def self.class_variables
+ [:@foo]
end
+end
+describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
it "matches when mod has the class variable, given as string" do
matcher = HaveClassVariableMatcher.new('@foo')
matcher.matches?(IVarModMock).should be_true
@@ -47,16 +47,3 @@ shared_examples_for "have_class_variable, on all Ruby versions" do
]
end
end
-
-describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
- before :all do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, '1.9.0'
-
- def IVarModMock.class_variables
- [:@foo]
- end
- end
-
- it_should_behave_like "have_class_variable, on all Ruby versions"
-end
diff --git a/spec/mspec/spec/matchers/have_instance_variable_spec.rb b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
index ababb38bc7..4122c6551b 100644
--- a/spec/mspec/spec/matchers/have_instance_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
@@ -2,9 +2,12 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-shared_examples_for "have_instance_variable, on all Ruby versions" do
- after :all do
- Object.const_set :RUBY_VERSION, @ruby_version
+describe HaveInstanceVariableMatcher do
+ before :each do
+ @object = Object.new
+ def @object.instance_variables
+ [:@foo]
+ end
end
it "matches when object has the instance variable, given as string" do
@@ -45,17 +48,3 @@ shared_examples_for "have_instance_variable, on all Ruby versions" do
]
end
end
-
-describe HaveInstanceVariableMatcher, "on RUBY_VERSION >= 1.9" do
- before :all do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, '1.9.0'
-
- @object = Object.new
- def @object.instance_variables
- [:@foo]
- end
- end
-
- it_should_behave_like "have_instance_variable, on all Ruby versions"
-end
diff --git a/spec/mspec/spec/runner/context_spec.rb b/spec/mspec/spec/runner/context_spec.rb
index f8759b639d..d9c20aa0cf 100644
--- a/spec/mspec/spec/runner/context_spec.rb
+++ b/spec/mspec/spec/runner/context_spec.rb
@@ -9,7 +9,7 @@ require 'mspec/runner/example'
describe ContextState, "#describe" do
before :each do
@state = ContextState.new "C#m"
- @proc = lambda {|*| ScratchPad.record :a }
+ @proc = proc { ScratchPad.record :a }
ScratchPad.clear
end
diff --git a/spec/mspec/spec/runner/mspec_spec.rb b/spec/mspec/spec/runner/mspec_spec.rb
index 9b8142414e..91338c6ddb 100644
--- a/spec/mspec/spec/runner/mspec_spec.rb
+++ b/spec/mspec/spec/runner/mspec_spec.rb
@@ -58,8 +58,8 @@ end
describe MSpec, ".retrieve" do
it "accesses .store'd data" do
- MSpec.register :action, :first
- MSpec.retrieve(:action).should == [:first]
+ MSpec.register :retrieve, :first
+ MSpec.retrieve(:retrieve).should == [:first]
end
end
diff --git a/spec/mspec/spec/spec_helper.rb b/spec/mspec/spec/spec_helper.rb
index 93e383ebb0..0d497f6627 100644
--- a/spec/mspec/spec/spec_helper.rb
+++ b/spec/mspec/spec/spec_helper.rb
@@ -48,7 +48,7 @@ def run_mspec(command, args)
ret = $?
out = out.sub(/\A\$.+\n/, '') # Remove printed command line
out = out.sub(RUBY_DESCRIPTION, "RUBY_DESCRIPTION")
- out = out.gsub(/\d\.\d{6}/, "D.DDDDDD") # Specs total time
+ out = out.gsub(/\d+\.\d{6}/, "D.DDDDDD") # Specs total time
out = out.gsub(/\d{2}:\d{2}:\d{2}/, "00:00:00") # Progress bar time
out = out.gsub(cwd, "CWD")
return out, ret
diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb
index 4073608ce3..deb7ab54fe 100644
--- a/spec/mspec/tool/sync/sync-rubyspec.rb
+++ b/spec/mspec/tool/sync/sync-rubyspec.rb
@@ -20,17 +20,18 @@ IMPLS = {
MSPEC = ARGV.delete('--mspec')
+MSPEC_REPO = File.expand_path("../../..", __FILE__)
+raise MSPEC_REPO if !Dir.exist?(MSPEC_REPO) or !Dir.exist?("#{MSPEC_REPO}/.git")
+
# Assuming the rubyspec repo is a sibling of the mspec repo
-RUBYSPEC_REPO = File.expand_path("../../../../rubyspec", __FILE__)
+RUBYSPEC_REPO = File.expand_path("../rubyspec", MSPEC_REPO)
raise RUBYSPEC_REPO unless Dir.exist?(RUBYSPEC_REPO)
-MSPEC_REPO = File.expand_path("../../../../mspec", __FILE__)
-raise MSPEC_REPO if MSPEC && !Dir.exist?(MSPEC_REPO)
-
SOURCE_REPO = MSPEC ? MSPEC_REPO : RUBYSPEC_REPO
NOW = Time.now
+BRIGHT_RED = "\e[31;1m"
BRIGHT_YELLOW = "\e[33;1m"
RESET = "\e[0m"
@@ -123,8 +124,14 @@ def rebase_commits(impl)
rebased = impl.rebased_branch
if branch?(rebased)
- puts "#{BRIGHT_YELLOW}#{rebased} already exists, assuming it correct#{RESET}"
- sh "git", "checkout", rebased
+ last_commit = Time.at(Integer(`git log -n 1 --format='%ct' #{rebased}`))
+ days_since_last_commit = (NOW-last_commit) / 86400
+ if days_since_last_commit > 7
+ abort "#{BRIGHT_RED}#{rebased} exists but last commit is old (#{last_commit}), delete the branch if it was merged#{RESET}"
+ else
+ puts "#{BRIGHT_YELLOW}#{rebased} already exists, last commit on #{last_commit}, assuming it correct#{RESET}"
+ sh "git", "checkout", rebased
+ end
else
sh "git", "checkout", impl.name
@@ -141,7 +148,7 @@ def rebase_commits(impl)
commit_date = Time.at(Integer(commit_timestamp))
days_since_last_merge = (NOW-commit_date) / 86400
if days_since_last_merge > 60
- raise "#{days_since_last_merge} since last merge, probably wrong commit"
+ raise "#{days_since_last_merge.floor} days since last merge, probably wrong commit"
end
puts "Rebasing..."