test_isolate: prevent concurrent execution
[rainbows.git] / t / test_isolate.rb
blobc8a88faa5d8582c34d923446ba271a122d11acef
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 'rack', '1.2.1'
20   gem 'kgio', '2.1.1'
21   gem 'unicorn', '3.3.0'
22   gem 'kcar', '0.1.1'
24   if engine == "ruby"
25     gem 'sendfile', '1.0.0' # next Rubinius should support this
27     gem 'iobuffer', '0.1.3'
28     gem 'cool.io', '1.0.0'
30     gem 'eventmachine', '0.12.10'
31     gem 'sinatra', '1.0.0'
32     gem 'async_sinatra', '0.4.0'
34     gem 'neverblock', '0.1.6.2'
35   end
37   if defined?(::Fiber) && engine == "ruby"
38     gem 'case', '0.5'
39     gem 'revactor', '0.1.5'
40     gem 'rack-fiber_pool', '0.9.0'
41   end
42 end
44 $stdout.reopen(old_out)
46 # don't load the old Rev if it exists, Cool.io 1.0.0 is compatible with it,
47 # even for everything Revactor uses.
48 dirs = Dir["#{path}/gems/*-*/lib"]
49 dirs.delete_if { |x| x =~ %r{/rev-[\d\.]+/lib} }
50 puts dirs.map { |x| File.expand_path(x) }.join(':')