Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 07b45c484540
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 27c255257a11
Choose a head ref
  • 4 commits
  • 22 files changed
  • 1 contributor

Commits on Aug 7, 2016

  1. Copy the full SHA
    e6cd2c6 View commit details
  2. Squashed 'spec/mspec/' changes from ea39a16..55caa7c

    55caa7c Hide our own deprecation warnings in tests
    aaf3156 Add spec for MSpec.deprecate
    640cccf Avoid rescuing exceptions silently
    e571785 Simplify TagFilter to use String#== over some complex escaped regexp
    d9e7077 Add a helper to set up the environment in the runner
    7aabadf Avoid non-standard API
    0e7f767 Make sure $MSPEC_DEBUG is initialized
    875583f Avoid monkey patches
    24e5ffe Fix not initialized warning in the argf helper
    2aa856d Define MSPEC_HOME once in options
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 55caa7cf16516f75baab6a3ce489b65b32c34782
    eregon committed Aug 7, 2016
    Copy the full SHA
    63f50ad View commit details
  3. Copy the full SHA
    f61619f View commit details
  4. Copy the full SHA
    27c2552 View commit details
2 changes: 0 additions & 2 deletions spec/mspec/lib/mspec/commands/mkspec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#! /usr/bin/env ruby

MSPEC_HOME = File.expand_path(File.dirname(__FILE__) + '/../../..')

require 'fileutils'
require 'rbconfig'
require 'mspec/version'
2 changes: 0 additions & 2 deletions spec/mspec/lib/mspec/commands/mspec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env ruby

MSPEC_HOME = File.expand_path(File.dirname(__FILE__) + '/../../..')

require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'
4 changes: 3 additions & 1 deletion spec/mspec/lib/mspec/helpers/argf.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@ def argf(argv)
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}"
end
raise "Cannot nest calls to the argf helper" if @argf || @__mspec_saved_argf_file__
if defined?(@argf) and (@argf || @__mspec_saved_argf_file__)
raise "Cannot nest calls to the argf helper"
end

@argf = ARGF.class.new(*argv)
@__mspec_saved_argf_file__ = @argf.file
5 changes: 0 additions & 5 deletions spec/mspec/lib/mspec/runner.rb
Original file line number Diff line number Diff line change
@@ -10,8 +10,3 @@
require 'mspec/runner/filters'
require 'mspec/runner/shared'
require 'mspec/runner/tag'

def $stderr.write(str)
# The 'useless use of' warnings are a crime against OO.
str =~ /useless use of/ ? nil : super
end
9 changes: 4 additions & 5 deletions spec/mspec/lib/mspec/runner/exception.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Initialize $MSPEC_DEBUG
$MSPEC_DEBUG = false unless defined?($MSPEC_DEBUG)

class ExceptionState
attr_reader :description, :describe, :it, :exception

@@ -33,11 +36,7 @@ def message
def backtrace
@backtrace_filter ||= MSpecScript.config[:backtrace_filter]

begin
bt = @exception.awesome_backtrace.show.split "\n"
rescue Exception
bt = @exception.backtrace || []
end
bt = @exception.backtrace || []

bt.select { |line| $MSPEC_DEBUG or @backtrace_filter !~ line }.join("\n")
end
14 changes: 7 additions & 7 deletions spec/mspec/lib/mspec/runner/filters/tag.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
require 'mspec/runner/filters/match'

class TagFilter
def initialize(what, *tags)
@what = what
@tags = tags
end

def load
desc = MSpec.read_tags(@tags).map { |t| t.description }

@filter = MatchFilter.new(@what, *desc)
@filter.register
@descriptions = MSpec.read_tags(@tags).map { |t| t.description }
MSpec.register @what, self
end

def unload
@filter.unregister if @filter
MSpec.unregister @what, self
end

def ===(string)
@descriptions.include?(string)
end

def register
2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/runner/formatters/dotted.rb
Original file line number Diff line number Diff line change
@@ -112,6 +112,6 @@ def print_exception(exc, count)
# A convenience method to allow printing to different outputs.
def print(*args)
@out.print(*args)
@out.flush rescue nil #IronRuby throws a .NET exception on IO.flush
@out.flush
end
end
9 changes: 6 additions & 3 deletions spec/mspec/lib/mspec/runner/mspec.rb
Original file line number Diff line number Diff line change
@@ -50,16 +50,19 @@ def self.files

shuffle files if randomize?
files.each do |file|
@env = Object.new
@env.extend MSpec

setup_env
store :file, file
actions :load
protect("loading #{file}") { Kernel.load file }
actions :unload
end
end

def self.setup_env
@env = Object.new
@env.extend MSpec
end

def self.actions(action, *args)
actions = retrieve(action)
actions.each { |obj| obj.send action, *args } if actions
3 changes: 1 addition & 2 deletions spec/mspec/lib/mspec/utils/deprecate.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module MSpec
def self.deprecate(what, replacement)
$stderr.puts "\n#{what} is deprecated, use #{replacement} instead."
user_caller = caller.find { |line| !line.include?('lib/mspec') }
$stderr.puts "from #{user_caller}"
$stderr.puts "\n#{what} is deprecated, use #{replacement} instead.\nfrom #{user_caller}"
end
end
2 changes: 2 additions & 0 deletions spec/mspec/lib/mspec/utils/options.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'mspec/version'

MSPEC_HOME = File.expand_path('../../../..', __FILE__)

class MSpecOption
attr_reader :short, :long, :arg, :description, :block

2 changes: 2 additions & 0 deletions spec/mspec/spec/guards/extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
end

before :each do
hide_deprecation_warnings
ScratchPad.clear
end

@@ -50,6 +51,7 @@

describe Object, "#extended_on" do
before :each do
hide_deprecation_warnings
@guard = ExtensionsGuard.new
ExtensionsGuard.stub(:new).and_return(@guard)
end
1 change: 1 addition & 0 deletions spec/mspec/spec/guards/version_spec.rb
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@
end

before :each do
hide_deprecation_warnings
@ruby_version = Object.const_get :RUBY_VERSION
@ruby_patch = Object.const_get :RUBY_PATCHLEVEL

8 changes: 8 additions & 0 deletions spec/mspec/spec/helpers/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -3,12 +3,20 @@
require 'mspec/helpers'

describe Object, "#hash_class" do
before :each do
hide_deprecation_warnings
end

it "returns the Hash class" do
hash_class.should == Hash
end
end

describe Object, "#new_hash" do
before :each do
hide_deprecation_warnings
end

it "returns a default hash" do
new_hash.should == {}
end
61 changes: 38 additions & 23 deletions spec/mspec/spec/runner/filters/tag_spec.rb
Original file line number Diff line number Diff line change
@@ -17,28 +17,17 @@
@filter.load
end

it "creates a MatchFilter from the descriptions matching the tags" do
MatchFilter.should_receive(:new).with(:include, "description").and_return(@match)
@filter.load
end

it "creates an empty MatchFilter if no tags were found" do
MSpec.should_receive(:read_tags).and_return([])
MatchFilter.should_receive(:new).with(:include).and_return(@match)
@filter.load
it "registers itself with MSpec for the :include action" do
filter = TagFilter.new(:include)
MSpec.should_receive(:register).with(:include, filter)
filter.load
end

it "registers the MatchFilter if there were tags found in the tag file" do
@match.should_receive(:register)
MatchFilter.should_receive(:new).with(:include, "description").and_return(@match)
@filter.load
end

it "registers the empty MatchFilter if no tags were found" do
@match.should_receive(:register)
MSpec.should_receive(:read_tags).and_return([])
MatchFilter.should_receive(:new).with(:include).and_return(@match)
@filter.load
it "registers itself with MSpec for the :exclude action" do
filter = TagFilter.new(:exclude)
MSpec.should_receive(:register).with(:exclude, filter)
filter.load
end
end

@@ -47,18 +36,21 @@
@filter = TagFilter.new :include, "tag", "key"
@tag = SpecTag.new "tag(comment):description"
MSpec.stub(:read_tags).and_return([@tag])
MSpec.stub(:register)
end

it "unregisters the MatchFilter if one was registered" do
match = double("match filter").as_null_object
match.should_receive(:unregister)
MatchFilter.stub(:new).with(:include, "description").and_return(match)
it "unregisters itself" do
@filter.load
MSpec.should_receive(:unregister).with(:include, @filter)
@filter.unload
end
end

describe TagFilter, "#register" do
before :each do
MSpec.stub(:register)
end

it "registers itself with MSpec for the :load, :unload actions" do
filter = TagFilter.new(nil)
MSpec.should_receive(:register).with(:load, filter)
@@ -68,10 +60,33 @@
end

describe TagFilter, "#unregister" do
before :each do
MSpec.stub(:unregister)
end

it "unregisters itself with MSpec for the :load, :unload actions" do
filter = TagFilter.new(nil)
MSpec.should_receive(:unregister).with(:load, filter)
MSpec.should_receive(:unregister).with(:unload, filter)
filter.unregister
end
end

describe TagFilter, "#===" do
before :each do
@filter = TagFilter.new nil, "tag", "key"
@tag = SpecTag.new "tag(comment):description"
MSpec.stub(:read_tags).and_return([@tag])
MSpec.stub(:register)
@filter.load
end

it "returns true if the argument matches any of the descriptions" do
@filter.===('description').should == true
end

it "returns false if the argument matches none of the descriptions" do
@filter.===('descriptionA').should == false
@filter.===('adescription').should == false
end
end
6 changes: 0 additions & 6 deletions spec/mspec/spec/runner/formatters/dotted_spec.rb
Original file line number Diff line number Diff line change
@@ -68,12 +68,6 @@
formatter = DottedFormatter.new
formatter.print "begonias"
end

it "rescues errors from flush" do
$stdout.should_receive(:flush).and_raise(RuntimeError.new)
formatter = DottedFormatter.new
formatter.print("begonias").should == nil
end
end

describe DottedFormatter, "#exception" do
2 changes: 2 additions & 0 deletions spec/mspec/spec/runner/shared_spec.rb
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
before :each do
ScratchPad.clear

MSpec.setup_env

@state = ContextState.new "Top level"
@state.instance_variable_set :@parsed, true

4 changes: 4 additions & 0 deletions spec/mspec/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -35,3 +35,7 @@ def new_option
# Just to have an exception name output not be "Exception"
class MSpecExampleError < Exception
end

def hide_deprecation_warnings
MSpec.stub(:deprecate)
end
17 changes: 17 additions & 0 deletions spec/mspec/spec/utils/deprecate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'
require 'mspec/utils/deprecate'

describe MSpec, "#deprecate" do
it "warns when using a deprecated method" do
warning = nil
$stderr.stub(:puts) { |str| warning = str }
MSpec.deprecate(:some_method, :other_method)
warning.should start_with(<<-EOS.chomp)
some_method is deprecated, use other_method instead.
from
EOS
warning.should include(__FILE__)
warning.should include('8')
end
end
2 changes: 2 additions & 0 deletions spec/truffle/tags/command_line/dash_upper_c_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:The -C command line option changes the PWD when using a file
fails:The -C command line option changes the PWD when using -e
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/zlib/deflate/deflate_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fails(OOM):Zlib::Deflate#deflate without break deflates chunked data with final chunk
fails(OOM):Zlib::Deflate#deflate without break deflates chunked data without errors
fails(OOM):Zlib::Deflate#deflate without break deflates chunked data
fails(OOM):Zlib::Deflate#deflate with break deflates only first chunk
fails(OOM):Zlib::Deflate#deflate with break deflates chunked data with final chunk
1 change: 1 addition & 0 deletions spec/truffle/tags/library/zlib/inflate/finish_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fails:Zlib::Inflate#finish inflates chunked data
slow:Zlib::Inflate#finish
slow:Zlib::Inflate#finish each chunk should have the same prefix
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/zlib/inflate/inflate_tags.txt
Original file line number Diff line number Diff line change
@@ -5,3 +5,5 @@ slow:Zlib::Inflate#inflate with break
slow:Zlib::Inflate#inflate without break
slow:Zlib::Inflate#inflate inflates lots of data
slow:Zlib::Inflate.inflate inflates lots of data
slow:Zlib::Inflate#inflate without break properly handles chunked data
slow:Zlib::Inflate#inflate with break inflates chunked break