support rack 2.x
[rainbows.git] / t / test_isolate.rb
blobbb56ef07e4f823a3757ca88ec6553c9fad8ef95d
1 require 'rubygems'
2 require 'isolate'
3 engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
5 path = "tmp/isolate/#{engine}-#{RUBY_VERSION}"
6 opts = {
7   :system => false,
8   # we want "ruby-1.8.7" and not "ruby-1.8", so disable multiruby
9   :multiruby => false,
10   :path => path,
13 old_out = $stdout.dup
14 $stdout.reopen($stderr)
16 lock = File.open(__FILE__, "rb")
17 lock.flock(File::LOCK_EX)
18 Isolate.now!(opts) do
19   gem 'kgio', '2.10.0'
20   gem 'rack', '2.0.1'
21   gem 'kcar', '0.6.0'
22   gem 'raindrops', '0.17.0'
23   gem 'unicorn', '5.2.0'
25   if engine == "ruby"
26     gem 'sendfile', '1.2.2'
27     gem 'eventmachine', '1.2.0.1'
29     # not compatible with rack 2.x
30     # gem 'async_sinatra', '1.2.1'
32     if RUBY_VERSION.to_f < 2.2
33       gem 'cool.io', '1.1.0'
34       gem 'neverblock', '0.1.6.2'
35     end
36   end
38   if defined?(::Fiber) && engine == "ruby"
39     if RUBY_VERSION.to_f < 2.2
40       gem 'revactor', '0.1.5'
41       gem 'rack-fiber_pool', '0.9.2' # depends on EM
42     end
43   end
45   if RUBY_PLATFORM =~ /linux/
46     gem 'sleepy_penguin', '3.4.1'
48     # is 2.6.32 new enough?
49     gem 'io_splice', '4.4.0' if `uname -r`.strip > '2.6.32'
50   end
51 end
53 $stdout.reopen(old_out)
55 # don't load the old Rev if it exists, Cool.io 1.0.0 is compatible with it,
56 # even for everything Revactor uses.
57 dirs = Dir["#{path}/gems/*-*/lib"]
58 dirs.delete_if { |x| x =~ %r{/rev-[\d\.]+/lib} }
59 puts dirs.map { |x| File.expand_path(x) }.join(':')