Skip to content

Commit ef716b7

Browse files
committed
childprocess only needed on mri; make ruby exec run with --1.9 in 1.9 mode
1 parent 034ff88 commit ef716b7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ group :development do
1111
gem "diff-lcs"
1212
gem "rcov", ">= 0.9.8"
1313
gem "rdoc"
14-
gem "childprocess"
14+
gem "childprocess", :platform => :mri
1515
end

spec/spec_helper.rb

+16-7
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,37 @@ def run_out_of_process_with_drb
8888
let(:drbclient) do
8989
drb
9090
DRbObject.new(nil, 'druby://127.0.0.1:7890').tap do |drbclient|
91-
ready = nil
92-
e = nil
93-
100.times { ((ready = drbclient.ready?) && break) rescue e = $!; sleep 0.5 }
94-
raise e unless ready
91+
ready, error = nil, nil
92+
300.times do # timeout 30 secs (300 * 0.1)
93+
begin
94+
break if ready = drbclient.ready?
95+
rescue DRb::DRbConnError => e
96+
error = e; sleep 0.1
97+
end
98+
end
99+
raise error unless ready
95100
end
96101
end
97102

98103
let(:drb_helper_args) { ["-I#{Warbler::WARBLER_HOME}/lib", File.join(@orig_dir, 'spec/drb_helper.rb')] }
99104

100105
if defined?(JRUBY_VERSION)
106+
require 'jruby'
101107
let(:drb) do
102-
Thread.new do
103-
ruby *drb_helper_args
108+
version_arg = JRuby.runtime.is1_9 ? "--1.9" : "--1.8"
109+
drb_thread = Thread.new do
110+
ruby *([ version_arg ] + drb_helper_args)
104111
end
112+
drb_thread.run
113+
drb_thread
105114
end
106115
after :each do
107116
drbclient.stop
108117
drb.join
109118
end
110119
else
120+
require 'childprocess'
111121
let(:drb) do
112-
require 'childprocess'
113122
ChildProcess.build(FileUtils::RUBY, *drb_helper_args).tap {|d| d.start }
114123
end
115124
after :each do

0 commit comments

Comments
 (0)