diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-10-04 23:55:31 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-10-04 23:56:18 +0000 |
commit | 9ef6b6f551a34922cfd831e2521495e89afe2f94 (patch) | |
tree | b041131b4ee0d5969b3b4e959112c660cf6d48dc /script | |
parent | 018a9deff4bd9273e053f369d746256e5b3ac99b (diff) | |
download | unicorn-9ef6b6f551a34922cfd831e2521495e89afe2f94.tar.gz |
We'll be using more of Isolate in development.
Diffstat (limited to 'script')
-rwxr-xr-x | script/isolate_for_tests | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/script/isolate_for_tests b/script/isolate_for_tests new file mode 100755 index 0000000..1919289 --- /dev/null +++ b/script/isolate_for_tests @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +# scripts/Makefiles can read and eval the output of this script and +# use it as RUBYLIB +require 'rubygems' +require 'isolate' +fp = File.open(__FILE__, "rb") +fp.flock(File::LOCK_EX) + +ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' +opts = { + :system => false, + # we want "ruby-1.8.7" and not "ruby-1.8", so disable :multiruby + :multiruby => false, + :path => "tmp/isolate/#{ruby_engine}-#{RUBY_VERSION}", +} + +pid = fork do + Isolate.now!(opts) do + gem 'sqlite3-ruby', '1.2.5' + gem 'rack', '1.1.0' + end +end +_, status = Process.waitpid2(pid) +status.success? or abort status.inspect +lib_paths = Dir["#{opts[:path]}/gems/*-*/lib"].map { |x| File.expand_path(x) } +libs = "tmp/isolate/.#{ruby_engine}-#{RUBY_VERSION}.libs" +File.open("#{libs}.#$$", "w") { |fp| fp.puts lib_paths.join(':') } +File.rename("#{libs}.#$$", libs) + +# pure Ruby gems can be shared across all Rubies +%w(3.0.0).each do |rails_ver| + opts[:path] = "tmp/isolate/rails-#{rails_ver}" + pid = fork do + Isolate.now!(opts) do + gem 'rails', rails_ver + end + end + _, status = Process.waitpid2(pid) + status.success? or abort status.inspect + more = Dir["#{opts[:path]}/gems/*-*/lib"].map { |x| File.expand_path(x) } + lib_paths.concat(more) +end |