Skip to content

Commit

Permalink
Merge pull request enkessler#122 from ms-ati/change-started-to-be-public
Browse files Browse the repository at this point in the history
Change 'ChildProcess#started?' to be public (rebased on 'dev')
  • Loading branch information
enkessler authored Sep 23, 2017
2 parents 18971e7 + 2ce583f commit a82b22d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
25 changes: 18 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ os:

rvm:
- 1.9.3
- jruby
- jruby-9.1.9.0
- rbx-3
- 2.0.0
- 2.1
- 2.2
- 2.3.3
- 2.4.0
- 2.3.5
- 2.4.1
- ruby-head
sudo: false

sudo: true # Necessary to fix JRuby

cache: bundler

before_install:
- "echo 'gem: --no-document' > ~/.gemrc"
- gem update --system
- gem install bundler # Necessary to fix 1.9.3

env:
- CHILDPROCESS_POSIX_SPAWN=true CHILDPROCESS_UNSET=should-be-unset
- CHILDPROCESS_POSIX_SPAWN=false CHILDPROCESS_UNSET=should-be-unset
global:
matrix:
- CHILDPROCESS_POSIX_SPAWN=true CHILDPROCESS_UNSET=should-be-unset
- CHILDPROCESS_POSIX_SPAWN=false CHILDPROCESS_UNSET=should-be-unset

matrix:
allow_failures:
- rvm: rbx-3
- rvm: ruby-head
env: "CHILDPROCESS_POSIX_SPAWN=true"
- env: "CHILDPROCESS_POSIX_SPAWN=true"
15 changes: 10 additions & 5 deletions lib/childprocess/abstract_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AbstractProcess
#
attr_accessor :cwd

#
#
# Set this to true to make the child process the leader of a new process group
#
Expand Down Expand Up @@ -115,6 +114,16 @@ def exited?
raise SubclassResponsibility, "exited?"
end

#
# Has the process started?
#
# @return [Boolean]
#

def started?
@started
end

#
# Is this process running?
#
Expand Down Expand Up @@ -159,10 +168,6 @@ def launch_process
raise SubclassResponsibility, "launch_process"
end

def started?
@started
end

def detach?
@detach
end
Expand Down
26 changes: 25 additions & 1 deletion spec/childprocess_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@

let(:logger) { Logger.new($stdout) }


it "logs to configured logger" do
cap = capture_std { generate_log_messages }

Expand All @@ -364,4 +363,29 @@

end

describe '#started?' do
subject { process.started? }

context 'when not started' do
let(:process) { sleeping_ruby(1) }

it { is_expected.to be false }
end

context 'when started' do
let(:process) { sleeping_ruby(1).start }

it { is_expected.to be true }
end

context 'when finished' do
before(:each) { process.wait }

let(:process) { sleeping_ruby(0).start }

it { is_expected.to be true }
end

end

end

0 comments on commit a82b22d

Please sign in to comment.