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: f1f870577f97
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a7847c96e1c2
Choose a head ref
  • 5 commits
  • 38 files changed
  • 1 contributor

Commits on Jun 27, 2016

  1. Squashed 'spec/mspec/' changes from 52e059d..ea39a16

    ea39a16 Only update the progress bar when needed in the SpinnerFormatter
    bf2b2c7 Fix specs for Ruby 2.4 Fixnum == Integer == Bignum
    
    git-subtree-dir: spec/mspec
    git-subtree-split: ea39a16925320ec65266a3ec3c39cf7bc808b7d0
    eregon committed Jun 27, 2016
    Copy the full SHA
    3e87852 View commit details
  2. Copy the full SHA
    846f743 View commit details
  3. Squashed 'spec/ruby/' changes from 842119c..9b80404

    9b80404 Use the block-style for #fork to clarify which is child/parent
    6105e6f Fix process leak in define_finalizer spec
    0d16336 Set the thread-local variable on a fresh thread to avoid adding one to the main thread
    6d6085b Add some specs for Fiber#resume and Fiber#transfer
    d74074c Fix name of Thread#thread_variable? spec
    d2646aa Clean up after some Fiber specs.
    ea9ba0f A couple Thread, Fiber spec fixes.
    3f3bfc9 Specs for Thread#thread_variable{s, _get, _set, _key?}.
    7e0030d Added ObjectSpace.define_finalizer specs.
    e36507d Improve coverage of Range#== and Range#eql? specs.
    2b8f656 [Truffle] Complete implementation of RSTRING_PTR.
    692a8c7 Add specs for Encoding.compatible?(String, Encoding).
    7da8db1 Add specs for Encoding.compatible?'s special handling of empty strings.
    7686226 Simplify scope changes in WeakRef#__send__ spec
    2ad4c51 Remove useless GC.start
    797a4ca Add a spec for `if $0 ==  __FILE__` with relative paths.
    d4fe65c [Truffle] Implement rb_funcall and rb_proc_new.
    517fba5 [Truffle] Pass all of Module C-extension specs.
    27fdf70 Fix description in rb_define_global_function spec
    cc2bbcc Specify what kind of NameError is acceptable for missing class variables
    202d106 Merge pull request #270 from odaira/myContribution
    9cdea79 Skip specs for getsockopt that are known to fail due to a bug in AIX
    8190a7c Close dup'd fd in Readline#readline spec
    1eddcf4 Fix spec trying to join a random process group
    0e41add Merge pull request #269 from odaira/myContribution
    2ded765 Avoid using the "daemon" group because it might not exist
    4025994 Merge pull request #268 from rhenium/skip-openssl-random-pesudo_bytes
    be27946 Skip OpenSSL::Random.pseudo_bytes if not defined
    5c234e5 Revert "Fix of MRI Bug 12367 was backported to 2.3 and 2.2"
    16c1d6a Fix of MRI Bug 12367 was backported to 2.3 and 2.2
    391bc02 Fix guards for C-API constants
    3ab19e5 Merge pull request #267 from nobu/integer-unification
    e7d61e0 Remove `rb_cFixnum` and `rb_cBignum`
    47d1d0f Merge 2 lines affecting the same variable in Process#setsid
    033ee7d Merge pull request #266 from odaira/myContribution
    c14030f AIX does not allow Process.getsid(pid) if pid is in a different session
    6c15fa6 Merge pull request #265 from iliabylich/mark-unsupported-specs-for-opal-as-unsupported
    4375899 Wrapped String#rindex specs containing regexp anchors with `not_supported_on :opal`.
    fea9678 Merge pull request #263 from duerst/Unicode-case-mapping
    0eef655 Update case mapping related in preparation for Unicode case mapping
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 9b80404bef43b67d0f9a82ab3005ffcbc1be49cd
    eregon committed Jun 27, 2016
    Copy the full SHA
    7727828 View commit details
  4. Copy the full SHA
    ce2ceca View commit details
  5. Copy the full SHA
    a7847c9 View commit details
Showing with 409 additions and 173 deletions.
  1. +21 −12 spec/mspec/lib/mspec/runner/formatters/spinner.rb
  2. +9 −12 spec/mspec/spec/runner/formatters/spinner_spec.rb
  3. +2 −2 spec/mspec/spec/utils/name_map_spec.rb
  4. +3 −0 spec/ruby/core/fiber/new_spec.rb
  5. +36 −0 spec/ruby/core/fiber/resume_spec.rb
  6. +2 −0 spec/ruby/core/fiber/yield_spec.rb
  7. +30 −1 spec/ruby/core/objectspace/define_finalizer_spec.rb
  8. +2 −1 spec/ruby/core/objectspace/each_object_spec.rb
  9. +7 −4 spec/ruby/core/process/setsid_spec.rb
  10. +5 −68 spec/ruby/core/range/eql_spec.rb
  11. +4 −0 spec/ruby/core/range/equal_value_spec.rb
  12. +46 −0 spec/ruby/core/range/fixtures/classes.rb
  13. +1 −1 spec/ruby/core/range/range_spec.rb
  14. +16 −4 spec/ruby/core/range/shared/equal_value.rb
  15. +6 −4 spec/ruby/core/string/capitalize_spec.rb
  16. +12 −10 spec/ruby/core/string/downcase_spec.rb
  17. +5 −3 spec/ruby/core/string/rindex_spec.rb
  18. +6 −4 spec/ruby/core/string/swapcase_spec.rb
  19. +12 −10 spec/ruby/core/string/upcase_spec.rb
  20. +13 −6 spec/ruby/core/symbol/capitalize_spec.rb
  21. +5 −3 spec/ruby/core/symbol/downcase_spec.rb
  22. +8 −6 spec/ruby/core/symbol/swapcase_spec.rb
  23. +4 −2 spec/ruby/core/symbol/upcase_spec.rb
  24. +25 −0 spec/ruby/core/thread/thread_variable_get_spec.rb
  25. +26 −0 spec/ruby/core/thread/thread_variable_set_spec.rb
  26. +21 −0 spec/ruby/core/thread/thread_variable_spec.rb
  27. +24 −0 spec/ruby/core/thread/thread_variables_spec.rb
  28. +3 −1 spec/ruby/library/etc/getgrnam_spec.rb
  29. +8 −0 spec/ruby/library/fiber/transfer_spec.rb
  30. +4 −2 spec/ruby/library/openssl/random/pseudo_bytes_spec.rb
  31. +1 −1 spec/ruby/library/openssl/random/random_bytes_spec.rb
  32. +3 −3 spec/ruby/library/openssl/random/shared/random_bytes.rb
  33. +2 −0 spec/ruby/library/readline/readline_spec.rb
  34. +12 −7 spec/ruby/library/socket/basicsocket/getsockopt_spec.rb
  35. +8 −4 spec/ruby/optional/capi/constants_spec.rb
  36. +4 −0 spec/ruby/optional/capi/ext/rubyspec.h
  37. +10 −0 spec/ruby/shared/fiber/resume.rb
  38. +3 −2 spec/ruby/shared/process/spawn.rb
33 changes: 21 additions & 12 deletions spec/mspec/lib/mspec/runner/formatters/spinner.rb
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ def register
super

MSpec.register :start, self
MSpec.register :load, self
MSpec.register :unload, self
MSpec.unregister :before, self
end

def length=(length)
@@ -36,8 +37,8 @@ def length=(length)
@position = length / 2 - 2
end

def etr
return "00:00:00" if @percent == 0
def compute_etr
return @etr = "00:00:00" if @percent == 0
elapsed = Time.now - @start
remain = (100 * elapsed / @percent) - elapsed

@@ -46,20 +47,25 @@ def etr
min = remain >= MIN ? (remain / MIN).to_i : 0
sec = remain - min * MIN

"%02d:%02d:%02d" % [hour, min, sec]
@etr = "%02d:%02d:%02d" % [hour, min, sec]
end

def percentage
def compute_percentage
@percent = @loaded * 100 / @total
bar = ("=" * (@percent / @ratio)).ljust @length
label = "%d%%" % @percent
bar[@position, label.size] = label
bar
@bar = bar
end

def compute_progress
compute_percentage
compute_etr
end

def progress_line
@which = (@which + 1) % Spins.size
data = [Spins[@which], percentage, etr, @counter.failures, @counter.errors]
data = [Spins[@which], @bar, @etr, @counter.failures, @counter.errors]
if @color
"\r[%s | %s | %s] \e[0;#{@fail_color}m%6dF \e[0;#{@error_color}m%6dE\e[0m" % data
else
@@ -75,12 +81,16 @@ def clear_progress_line
# number of files that will be processed.
def start
@total = MSpec.retrieve(:files).size
compute_progress
print progress_line
end

# Callback for the MSpec :load event. Increments the number
# of files that have been loaded.
def load
# Callback for the MSpec :unload event. Increments the number
# of files that have been run.
def unload
@loaded += 1
compute_progress
print progress_line
end

# Callback for the MSpec :exception event. Changes the color
@@ -94,8 +104,7 @@ def exception(exception)
print_exception(exception, @count)
end

# Callback for the MSpec :after event. Updates the spinner
# and progress bar.
# Callback for the MSpec :after event. Updates the spinner.
def after(state)
print progress_line
end
21 changes: 9 additions & 12 deletions spec/mspec/spec/runner/formatters/spinner_spec.rb
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@

it "registers self with MSpec for appropriate actions" do
MSpec.should_receive(:register).with(:start, @formatter)
MSpec.should_receive(:register).with(:load, @formatter)
MSpec.should_receive(:register).with(:unload, @formatter)
MSpec.should_receive(:register).with(:after, @formatter)
MSpec.should_receive(:register).with(:finish, @formatter)
@formatter.register
@@ -55,7 +55,7 @@
describe SpinnerFormatter, "#after" do
before :each do
$stdout = IOStub.new
MSpec.stub(:retrieve).and_return(["a", "b"])
MSpec.store(:files, ["a", "b", "c", "d"])
@formatter = SpinnerFormatter.new
@formatter.register
@state = ExampleState.new("describe", "it")
@@ -67,20 +67,17 @@

it "updates the spinner" do
@formatter.start
@formatter.load
@formatter.after @state
@formatter.after @state
@formatter.unload

output = nil
if ENV["TERM"] != "dumb"
output = "\r[/ | ======== 20% | 00:00:00] " \
"\e[0;32m 0F \e[0;32m 0E\e[0m" \
"\r[- | ======== 20% | 00:00:00] " \
"\e[0;32m 0F \e[0;32m 0E\e[0m"
else
output = "\r[/ | ======== 20% | 00:00:00] 0F 0E" \
"\r[- | ======== 20% | 00:00:00] 0F 0E"
green = "\e[0;32m"
reset = "\e[0m"
end

output = "\r[/ | 0% | 00:00:00] #{green} 0F #{green} 0E#{reset}" \
"\r[- | 0% | 00:00:00] #{green} 0F #{green} 0E#{reset}" \
"\r[\\ | ========== 25% | 00:00:00] #{green} 0F #{green} 0E#{reset}"
$stdout.should == output
end
end
4 changes: 2 additions & 2 deletions spec/mspec/spec/utils/name_map_spec.rb
Original file line number Diff line number Diff line change
@@ -149,11 +149,11 @@ def n; end
end

it "prepends the module to the constant name" do
@map.namespace("SubModule", Fixnum).should == "SubModule::Fixnum"
@map.namespace("SubModule", Integer).should == "SubModule::Integer"
end

it "does not prepend Object, Class, or Module to the constant name" do
@map.namespace("Object", Fixnum).should == "Fixnum"
@map.namespace("Object", String).should == "String"
@map.namespace("Module", Integer).should == "Integer"
@map.namespace("Class", Float).should == "Float"
end
3 changes: 3 additions & 0 deletions spec/ruby/core/fiber/new_spec.rb
Original file line number Diff line number Diff line change
@@ -4,13 +4,15 @@
describe "Fiber.new" do
it "creates a fiber from the given block" do
fiber = Fiber.new {}
fiber.resume
fiber.should be_an_instance_of(Fiber)
end

it "creates a fiber from a subclass" do
class MyFiber < Fiber
end
fiber = MyFiber.new {}
fiber.resume
fiber.should be_an_instance_of(MyFiber)
end

@@ -22,6 +24,7 @@ class MyFiber < Fiber
invoked = false
fiber = Fiber.new { invoked = true }
invoked.should be_false
fiber.resume
end

it "closes over lexical environments" do
36 changes: 36 additions & 0 deletions spec/ruby/core/fiber/resume_spec.rb
Original file line number Diff line number Diff line change
@@ -12,5 +12,41 @@
fiber2 = Fiber.new { fiber1.resume; :fiber2 }
fiber2.resume.should == :fiber2
end

# Redmine #595
it "executes the ensure clause" do
rd, wr = IO.pipe

pid = Kernel::fork do
rd.close
f = Fiber.new do
begin
Fiber.yield
ensure
wr.write "executed"
end
end

# The apparent issue is that when Fiber.yield executes, control
# "leaves" the "ensure block" and so the ensure clause should run. But
# control really does NOT leave the ensure block when Fiber.yield
# executes. It merely pauses there. To require ensure to run when a
# Fiber is suspended then makes ensure-in-a-Fiber-context different
# than ensure-in-a-Thread-context and this would be very confusing.
f.resume

# When we execute the second #resume call, the ensure block DOES exit,
# the ensure clause runs. This is Ruby behavior as of 2.3.1.
f.resume

exit 0
end

wr.close
Process.waitpid pid

rd.read.should == "executed"
rd.close
end
end
end
2 changes: 2 additions & 0 deletions spec/ruby/core/fiber/yield_spec.rb
Original file line number Diff line number Diff line change
@@ -14,11 +14,13 @@
it "returns its arguments to the caller" do
fiber = Fiber.new { true; Fiber.yield :glark; true }
fiber.resume.should == :glark
fiber.resume
end

it "returns nil to the caller if given no arguments" do
fiber = Fiber.new { true; Fiber.yield; true }
fiber.resume.should be_nil
fiber.resume
end

it "returns to the Fiber the value of the #resume call that invoked it" do
31 changes: 30 additions & 1 deletion spec/ruby/core/objectspace/define_finalizer_spec.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
describe "ObjectSpace.define_finalizer" do
it "raises an ArgumentError if the action does not respond to call" do
lambda {
ObjectSpace.define_finalizer("", 3)
ObjectSpace.define_finalizer("", mock("ObjectSpace.define_finalizer no #call"))
}.should raise_error(ArgumentError)
end

@@ -78,5 +78,34 @@ def handler.call(obj) end
Process.wait pid
end
end

# These specs are defined under the fork specs because there is no
# deterministic way to force finalizers to be run, except process exit, so
# we rely on that.
it "allows multiple finalizers with different 'callables' to be defined" do
rd1, wr1 = IO.pipe
rd2, wr2 = IO.pipe

pid = Kernel::fork do
rd1.close
rd2.close
obj = mock("ObjectSpace.define_finalizer multiple")

ObjectSpace.define_finalizer(obj, Proc.new { wr1.write "finalized1"; wr1.close })
ObjectSpace.define_finalizer(obj, Proc.new { wr2.write "finalized2"; wr2.close })

exit 0
end

wr1.close
wr2.close

rd1.read.should == "finalized1"
rd2.read.should == "finalized2"

rd1.close
rd2.close
Process.wait pid
end
end
end
3 changes: 2 additions & 1 deletion spec/ruby/core/objectspace/each_object_spec.rb
Original file line number Diff line number Diff line change
@@ -130,7 +130,8 @@ class ObjectSpaceSpecEachOtherObject; end
end

it "finds an object stored in a thread local" do
Thread.current.thread_variable_set(:object_space_thread_local, ObjectSpaceFixtures::ObjectToBeFound.new(:thread_local))
thread = Thread.new {}
thread.thread_variable_set(:object_space_thread_local, ObjectSpaceFixtures::ObjectToBeFound.new(:thread_local))
ObjectSpaceFixtures.to_be_found_symbols.should include(:thread_local)
end

11 changes: 7 additions & 4 deletions spec/ruby/core/process/setsid_spec.rb
Original file line number Diff line number Diff line change
@@ -20,14 +20,17 @@
}
write.close
read2.close
pgid_child = read.gets
pgid_child = Integer(read.gets)
read.close
pgid = Process.getsid(pid)
platform_is_not :aix do
# AIX does not allow Process.getsid(pid)
# if pid is in a different session.
pgid = Process.getsid(pid)
pgid_child.should == pgid
end
write2.close
Process.wait pid

pgid_child = Integer(pgid_child)
pgid_child.should == pgid
pgid_child.should_not == Process.getsid
end
end
73 changes: 5 additions & 68 deletions spec/ruby/core/range/eql_spec.rb
Original file line number Diff line number Diff line change
@@ -1,73 +1,10 @@
# Custom Range classes Xs and Ys
class Custom
include Comparable
attr :length
def initialize(n)
@length = n
end
def eql?(other)
inspect.eql? other.inspect
end
def inspect
'custom'
end
def <=>(other)
@length <=> other.length
end
def to_s
sprintf "%2d #{inspect}", @length
end
end

class Xs < Custom # represent a string of 'x's
def succ
Xs.new(@length + 1)
end
def inspect
'x' * @length
end
end

class Ys < Custom # represent a string of 'y's
def succ
Ys.new(@length + 1)
end
def inspect
'y' * @length
end
end
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/equal_value', __FILE__)

describe :range_eql, shared: true do
it "returns true if other has same begin, end, and exclude_end? values" do
(0..2).send(@method, 0..2).should == true
('G'..'M').send(@method,'G'..'M').should == true
(0.5..2.4).send(@method, 0.5..2.4).should == true
(5..10).send(@method, Range.new(5,10)).should == true
('D'..'V').send(@method, Range.new('D','V')).should == true
(0.5..2.4).send(@method, Range.new(0.5, 2.4)).should == true
(0xffff..0xfffff).send(@method, 0xffff..0xfffff).should == true
(0xffff..0xfffff).send(@method, Range.new(0xffff,0xfffff)).should == true
(Xs.new(3)..Xs.new(5)).send(@method, Range.new(Xs.new(3), Xs.new(5))).should == true
describe "Range#eql?" do
it_behaves_like(:range_eql, :eql?)

it "returns false if the endpoints are not eql?" do
(0..1).send(@method, 0..1.0).should == false
('Q'..'X').send(@method, 'A'..'C').should == false
('Q'...'X').send(@method, 'Q'..'W').should == false
('Q'..'X').send(@method, 'Q'...'X').should == false
(0.5..2.4).send(@method, 0.5...2.4).should == false
(1482..1911).send(@method, 1482...1911).should == false
(0xffff..0xfffff).send(@method, 0xffff...0xfffff).should == false
(Xs.new(3)..Xs.new(5)).send(@method, Range.new(Ys.new(3), Ys.new(5))).should == false
end

it "returns false if other is no Range" do
(1..10).send(@method, 1).should == false
(1..10).send(@method, 'a').should == false
(1..10).send(@method, mock('x')).should == false
end

it "returns true for subclasses to Range" do
class MyRange < Range ; end
Range.new(1, 2).send(@method, MyRange.new(1, 2)).should == true
Range.new(Xs.new(3), Xs.new(5)).send(@method, MyRange.new(Xs.new(3), Xs.new(5))).should == true
end
end
4 changes: 4 additions & 0 deletions spec/ruby/core/range/equal_value_spec.rb
Original file line number Diff line number Diff line change
@@ -3,4 +3,8 @@

describe "Range#==" do
it_behaves_like(:range_eql, :==)

it "returns true if the endpoints are ==" do
(0..1).send(@method, 0..1.0).should == true
end
end
Loading