ruby-changes:47792
From: eregon <ko1@a...>
Date: Fri, 15 Sep 2017 00:56:16 +0900 (JST)
Subject: [ruby-changes:47792] eregon:r59909 (trunk): Update to ruby/mspec@5bd9409
eregon 2017-09-15 00:56:09 +0900 (Fri, 15 Sep 2017) New Revision: 59909 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59909 Log: Update to ruby/mspec@5bd9409 Removed files: trunk/spec/mspec/mspec.gemspec Modified files: trunk/spec/mspec/.travis.yml trunk/spec/mspec/Gemfile trunk/spec/mspec/Gemfile.lock trunk/spec/mspec/README.md trunk/spec/mspec/lib/mspec/matchers/raise_error.rb trunk/spec/mspec/lib/mspec/mocks/mock.rb trunk/spec/mspec/lib/mspec/runner/formatters/multi.rb trunk/spec/mspec/lib/mspec/runner/mspec.rb trunk/spec/mspec/lib/mspec/utils/script.rb trunk/spec/mspec/lib/mspec/utils/warnings.rb trunk/spec/mspec/spec/commands/mkspec_spec.rb trunk/spec/mspec/spec/commands/mspec_ci_spec.rb trunk/spec/mspec/spec/guards/guard_spec.rb trunk/spec/mspec/spec/guards/support_spec.rb trunk/spec/mspec/spec/helpers/io_spec.rb trunk/spec/mspec/spec/matchers/be_kind_of_spec.rb trunk/spec/mspec/spec/matchers/have_class_variable_spec.rb trunk/spec/mspec/spec/matchers/have_instance_variable_spec.rb trunk/spec/mspec/spec/runner/context_spec.rb trunk/spec/mspec/spec/runner/mspec_spec.rb trunk/spec/mspec/spec/spec_helper.rb trunk/spec/mspec/tool/sync/sync-rubyspec.rb Index: spec/mspec/mspec.gemspec =================================================================== --- spec/mspec/mspec.gemspec (revision 59908) +++ spec/mspec/mspec.gemspec (nonexistent) @@ -1,40 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/mspec.gemspec#L0 -# -*- 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@e..."] - 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 Index: spec/mspec/README.md =================================================================== --- spec/mspec/README.md (revision 59908) +++ spec/mspec/README.md (revision 59909) @@ -33,6 +33,9 @@ specs in a manner compatible with multip https://github.com/ruby/ruby/blob/trunk/spec/mspec/README.md#L33 configuration facility with a default project file and user-specific overrides. +## Requirements + +MSpec requires Ruby 2.2 or more recent. ## Bundler Index: spec/mspec/tool/sync/sync-rubyspec.rb =================================================================== --- spec/mspec/tool/sync/sync-rubyspec.rb (revision 59908) +++ spec/mspec/tool/sync/sync-rubyspec.rb (revision 59909) @@ -20,17 +20,18 @@ IMPLS = { https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L20 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) https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L124 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) https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L148 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..." Index: spec/mspec/Gemfile.lock =================================================================== --- spec/mspec/Gemfile.lock (revision 59908) +++ spec/mspec/Gemfile.lock (revision 59909) @@ -1,8 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/Gemfile.lock#L1 -PATH - remote: . - specs: - mspec (1.8.0) - GEM remote: https://rubygems.org/ specs: @@ -22,9 +17,8 @@ PLATFORMS https://github.com/ruby/ruby/blob/trunk/spec/mspec/Gemfile.lock#L17 ruby DEPENDENCIES - mspec! rake (~> 10.0) rspec (~> 2.14.1) BUNDLED WITH - 1.10.2 + 1.14.5 Index: spec/mspec/.travis.yml =================================================================== --- spec/mspec/.travis.yml (revision 59908) +++ spec/mspec/.travis.yml (revision 59909) @@ -2,8 +2,14 @@ sudo: false https://github.com/ruby/ruby/blob/trunk/spec/mspec/.travis.yml#L2 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 Index: spec/mspec/lib/mspec/utils/warnings.rb =================================================================== --- spec/mspec/lib/mspec/utils/warnings.rb (revision 59908) +++ spec/mspec/lib/mspec/utils/warnings.rb (revision 59909) @@ -4,6 +4,7 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSIO https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/warnings.rb#L4 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_VERSIO https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/warnings.rb#L17 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/ Index: spec/mspec/lib/mspec/utils/script.rb =================================================================== --- spec/mspec/lib/mspec/utils/script.rb (revision 59908) +++ spec/mspec/lib/mspec/utils/script.rb (revision 59909) @@ -38,6 +38,10 @@ class MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/script.rb#L38 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] = [] Index: spec/mspec/lib/mspec/matchers/raise_error.rb =================================================================== --- spec/mspec/lib/mspec/matchers/raise_error.rb (revision 59908) +++ spec/mspec/lib/mspec/matchers/raise_error.rb (revision 59909) @@ -5,16 +5,18 @@ class RaiseErrorMatcher https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L5 @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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L56 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)" Index: spec/mspec/lib/mspec/runner/formatters/multi.rb =================================================================== --- spec/mspec/lib/mspec/runner/formatters/multi.rb (revision 59908) +++ spec/mspec/lib/mspec/runner/formatters/multi.rb (revision 59909) @@ -1,5 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/formatters/multi.rb#L1 require 'mspec/runner/formatters/spinner' -require 'yaml' class MultiFormatter < SpinnerFormatter def initialize(out=nil) @@ -10,6 +9,8 @@ class MultiFormatter < SpinnerFormatter https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/formatters/multi.rb#L9 end def aggregate_results(files) + require 'yaml' + @timer.finish @exceptions = [] Index: spec/mspec/lib/mspec/runner/mspec.rb =================================================================== --- spec/mspec/lib/mspec/runner/mspec.rb (revision 59908) +++ spec/mspec/lib/mspec/runner/mspec.rb (revision 59909) @@ -2,6 +2,9 @@ require 'mspec/runner/context' https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/mspec.rb#L2 require 'mspec/runner/exception' require 'mspec/runner/tag' +module MSpec +end + class MSpecEnv include MSpec end @@ -399,4 +402,7 @@ module MSpec https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/mspec.rb#L402 file = tags_file File.delete file if File.exist? file end + + # Initialize @env + setup_env end Index: spec/mspec/lib/mspec/mocks/mock.rb =================================================================== --- spec/mspec/lib/mspec/mocks/mock.rb (revision 59908) +++ spec/mspec/lib/mspec/mocks/mock.rb (revision 59909) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/mocks/mock.rb#L1 require 'mspec/expectations/expectations' +require 'mspec/helpers/warning' module Mock def self.reset @@ -57,10 +58,12 @@ module Mock https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/mocks/mock.rb#L58 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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/mocks/mock.rb#L182 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 Index: spec/mspec/Gemfile =================================================================== --- spec/mspec/Gemfile (revision 59908) +++ spec/mspec/Gemfile (revision 59909) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/Gemfile#L1 source 'https://rubygems.org' -# Specify your gem's dependencies in mspec.gemspec -gemspec +gem "rake", "~> 10.0" +gem "rspec", "~> 2.14.1" Index: spec/mspec/spec/runner/context_spec.rb =================================================================== --- spec/mspec/spec/runner/context_spec.rb (revision 59908) +++ spec/mspec/spec/runner/context_spec.rb (revision 59909) @@ -9,7 +9,7 @@ require 'mspec/runner/example' https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/runner/context_spec.rb#L9 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 Index: spec/mspec/spec/runner/mspec_spec.rb =================================================================== --- spec/mspec/spec/runner/mspec_spec.rb (revision 59908) +++ spec/mspec/spec/runner/mspec_spec.rb (revision 59909) @@ -58,8 +58,8 @@ end https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/runner/mspec_spec.rb#L58 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 Index: spec/mspec/spec/spec_helper.rb =================================================================== --- spec/mspec/spec/spec_helper.rb (revision 59908) +++ spec/mspec/spec/spec_helper.rb (revision 59909) @@ -48,7 +48,7 @@ def run_mspec(command, args) https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/spec_helper.rb#L48 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 Index: spec/mspec/spec/commands/mkspec_spec.rb =================================================================== --- spec/mspec/spec/commands/mkspec_spec.rb (revision 59908) +++ spec/mspec/spec/commands/mkspec_spec.rb (revision 59909) @@ -38,7 +38,7 @@ describe "The -b, --base DIR option" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mkspec_spec.rb#L38 @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 opti https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mkspec_spec.rb#L62 @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 VERSIO https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mkspec_spec.rb#L86 @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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mkspec_spec.rb#L119 @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 Index: spec/mspec/spec/commands/mspec_ci_spec.rb =================================================================== --- spec/mspec/spec/commands/mspec_ci_spec.rb (revision 59908) +++ spec/mspec/spec/commands/mspec_ci_spec.rb (revision 59909) @@ -15,17 +15,17 @@ describe MSpecCI, "#options" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mspec_ci_spec.rb#L15 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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mspec_ci_spec.rb#L35 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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/commands/mspec_ci_spec.rb#L99 @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 Index: spec/mspec/spec/helpers/io_spec.rb =================================================================== --- spec/mspec/spec/helpers/io_spec.rb (revision 59908) +++ spec/mspec/spec/helpers/io_spec.rb (revision 59909) @@ -60,9 +60,9 @@ describe Object, "#new_fd" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/helpers/io_spec.rb#L60 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 https://github.com/ruby/ruby/ (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/