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: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fbaafa65ea49^
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e25088a37f27
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 4, 2015

  1. Added simple spec for Process::Status#initialize.

    While MRI removes the `new` method from Process::Status we _do_ have this method
    (and an initialize method) that perform certain actions worth testing. More
    importantly, this way we can ensure that this class can be initialized from C in
    a similar fashion to MRI.
    
    See #3268 for more information.
    Yorick Peterse committed Jan 4, 2015
    Copy the full SHA
    fbaafa6 View commit details
  2. Make Process::Status#initialize arguments optional

    This ensures that the class can be initialized in a similar fashion to MRI
    (mainly from C land) while still keeping it compatible with existing Rubinius
    code.
    Yorick Peterse committed Jan 4, 2015
    Copy the full SHA
    1ac896d View commit details
  3. Added specs for Process::Status#exitstatus.

    Yorick Peterse committed Jan 4, 2015
    Copy the full SHA
    ee3cf92 View commit details
  4. Use "status" ivar in Process::Status.

    MRI stores the status code in an instance variable called "@status" instead of
    "@ExitStatus". Due to the lack of a proper API to set this variable people
    instead have to resort to setting it via rb_ivar_set() in C. To ensure
    compatibility with MRI we sadly also have to name this variable in the same way.
    
    Due to the variable being renamed the method "exitstatus" now has to be manually
    defined, instead of just being an attribute reader.
    
    See #3268 for more information.
    Yorick Peterse committed Jan 4, 2015
    Copy the full SHA
    e25088a View commit details
Showing with 27 additions and 10 deletions.
  1. +13 −10 kernel/common/process.rb
  2. +7 −0 spec/ruby/core/process/exitstatus_spec.rb
  3. +7 −0 spec/ruby/core/process/initialize_spec.rb
23 changes: 13 additions & 10 deletions kernel/common/process.rb
Original file line number Diff line number Diff line change
@@ -522,44 +522,47 @@ def self.coerce_rlimit_resource(resource)

class Status

attr_reader :exitstatus
attr_reader :termsig
attr_reader :stopsig

def initialize(pid, exitstatus, termsig=nil, stopsig=nil)
def initialize(pid=nil, status=nil, termsig=nil, stopsig=nil)
@pid = pid
@exitstatus = exitstatus
@status = status
@termsig = termsig
@stopsig = stopsig
end

def exitstatus
return @status
end

def to_i
@exitstatus
@status
end

def to_s
@exitstatus.to_s
@status.to_s
end

def &(num)
@exitstatus & num
@status & num
end

def ==(other)
other = other.to_i if other.kind_of? Process::Status
@exitstatus == other
@status == other
end

def >>(num)
@exitstatus >> num
@status >> num
end

def coredump?
false
end

def exited?
@exitstatus != nil
@status != nil
end

def pid
@@ -576,7 +579,7 @@ def stopped?

def success?
if exited?
@exitstatus == 0
@status == 0
else
nil
end
7 changes: 7 additions & 0 deletions spec/ruby/core/process/exitstatus_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe 'Process::Status#exitstatus' do
it 'returns the exit status as a Fixnum' do
Process::Status.new(42, 1).exitstatus.should == 1
end
end
7 changes: 7 additions & 0 deletions spec/ruby/core/process/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe 'Process::Status#initialize' do
it 'initializes a new Process::Status instance' do
Process::Status.new.should be_an_instance_of(Process::Status)
end
end