From 0a3e9cacd7ca2feb91bae23b0c678d5e986f866f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 11 Jun 2010 08:47:41 +0000 Subject: update test infrastructure to support Rubinius Rubinius still has a few issues that prevent 100% support, but it basically works if log rotation or USR2 upgrades aren't required. Tickets for all known issues for Rubinius have been filed on the project's issue tracker. * rbx does not support -i/-p yet, so rely on MRI for that * "io/nonblock" is missing * avoiding any optional Gems for now (EM, Rev, etc..) --- GNUmakefile | 8 +++++--- lib/rainbows/base.rb | 2 +- t/.gitignore | 2 +- t/GNUmakefile | 38 ++++++++++++++++++++++---------------- t/test-lib.sh | 2 +- t/test_isolate.rb | 22 ++++++++++++---------- 6 files changed, 42 insertions(+), 32 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 32a1b8c..2474db8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,6 @@ # use GNU Make to run tests in parallel, and without depending on RubyGems all:: +MRI = ruby RUBY = ruby RAKE = rake RSYNC = rsync @@ -15,6 +16,7 @@ endif ifeq ($(RUBY_VERSION),) RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION') endif +RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))') base_bins := rainbows bins := $(addprefix bin/, $(base_bins)) @@ -91,16 +93,16 @@ doc: .document NEWS ChangeLog < $${i}_1.html > tmp && mv tmp $${i}_1.html; \ ln $${i}_1.html $${i}.1.html; \ done - $(RUBY) -i -p -e \ + $(MRI) -i -p -e \ '$$_.gsub!("",%q{\&$(call atom,$(cgit_atom))})' \ doc/ChangeLog.html - $(RUBY) -i -p -e \ + $(MRI) -i -p -e \ '$$_.gsub!("",%q{\&$(call atom,$(news_atom))})' \ doc/NEWS.html doc/README.html $(RAKE) -s news_atom > doc/NEWS.atom.xml cd doc && ln README.html tmp && mv tmp index.html $(MAKE) -C Documentation comparison.html - $(RUBY) -i -p -e \ + $(MRI) -i -p -e \ '$$_.gsub!(/INCLUDE/){File.read("Documentation/comparison.html")}' \ doc/Summary.html cat Documentation/comparison.css >> doc/rdoc.css diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 8e5031f..86ec733 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -16,7 +16,7 @@ module Rainbows G.tmp = worker.tmp # avoid spurious wakeups and blocking-accept() with 1.8 green threads - if RUBY_VERSION.to_f < 1.9 + if ! defined?(RUBY_ENGINE) && RUBY_VERSION.to_f < 1.9 require "io/nonblock" HttpServer::LISTENERS.each { |l| l.nonblock = true } end diff --git a/t/.gitignore b/t/.gitignore index ca24c05..f810a71 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -1,5 +1,5 @@ /test-results-* -/test-bin-* +/bin-* /random_blob /.dep+* /trash diff --git a/t/GNUmakefile b/t/GNUmakefile index 2e86d24..2402257 100644 --- a/t/GNUmakefile +++ b/t/GNUmakefile @@ -4,6 +4,7 @@ all:: pid := $(shell echo $$PPID) +MRI = ruby RUBY = ruby rainbows_lib := $(shell cd ../lib && pwd) -include ../local.mk @@ -15,7 +16,8 @@ ifeq ($(RUBY_VERSION),) $(error unable to detect RUBY_VERSION) endif -export RUBY_VERSION +RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))') +export RUBY_VERSION RUBY_ENGINE models += WriterThreadPool models += WriterThreadSpawn @@ -27,13 +29,15 @@ models += NeverBlock models += RevThreadSpawn models += RevThreadPool -rp := ) -ONENINE := $(shell case $(RUBY_VERSION) in 1.9.*$(rp) echo true;;esac) -ifeq ($(ONENINE),true) - models += Revactor - models += FiberSpawn - models += RevFiberSpawn - models += FiberPool +ifeq ($(RUBY_ENGINE),ruby) + rp := ) + ONENINE := $(shell case $(RUBY_VERSION) in 1.9.*$(rp) echo true;;esac) + ifeq ($(ONENINE),true) + models += Revactor + models += FiberSpawn + models += RevFiberSpawn + models += FiberPool + endif endif all_models := $(models) Base @@ -60,7 +64,7 @@ $(all_models): all:: $(T) # can't rely on "set -o pipefail" since we don't require bash or ksh93 :< -t_pfx = trash/$@-$(RUBY_VERSION) +t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION) TEST_OPTS = # TRACER = strace -f -o $(t_pfx).strace -s 100000 # TRACER = /usr/bin/time -o $(t_pfx).time @@ -73,11 +77,13 @@ ifdef V endif endif -test-bin-$(RUBY_VERSION)/rainbows: ruby_bin = $(shell which $(RUBY)) -test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows +bindir := $(CURDIR)/bin-$(RUBY_ENGINE)-$(RUBY_VERSION) +bin_rainbows := $(bindir)/rainbows +$(bin_rainbows): ruby_bin = $(shell which $(RUBY)) +$(bin_rainbows): ../bin/rainbows mkdir -p $(@D) install -m 755 $^ $@.$(pid) - $(RUBY) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.$(pid) + $(MRI) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.$(pid) mv $@.$(pid) $@ random_blob: @@ -95,18 +101,18 @@ $(deps): { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; } @mv $@.$(pid) $@ -libs := tmp/isolate/ruby-$(RUBY_VERSION)/.libs +libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/.libs $(libs): test_isolate.rb mkdir -p $(@D) $(RUBY) $< > $@+ mv $@+ $@ -t_deps := $(libs) $(deps) test-bin-$(RUBY_VERSION)/rainbows trash/.gitignore +t_deps := $(libs) $(deps) $(bin_rainbows) trash/.gitignore $(T): $(t_deps) $(MODEL_T): export model = $(firstword $(subst ., ,$@)) $(MODEL_T): script = $(subst $(model).,,$@) $(MODEL_T): export RUBY := $(RUBY) -$(MODEL_T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH) +$(MODEL_T): export PATH := $(bindir):$(PATH) $(MODEL_T): $(t_deps) RUBYLIB=$(rainbows_lib):$$(cat $(libs)) \ $(TRACER) $(SHELL) $(SH_TEST_OPTS) $(script) $(TEST_OPTS) @@ -116,6 +122,6 @@ trash/.gitignore: echo '*' > $@ clean: - $(RM) -r trash/*.log trash/*.code test-bin-$(RUBY_VERSION) + $(RM) -r trash/*.log trash/*.code $(bindir) .PHONY: $(T) clean diff --git a/t/test-lib.sh b/t/test-lib.sh index 4218dff..0fea06b 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -19,7 +19,7 @@ fi set -e RUBY="${RUBY-ruby}" RUBY_VERSION=${RUBY_VERSION-$($RUBY -e 'puts RUBY_VERSION')} -t_pfx=$PWD/trash/$model.$T-$RUBY_VERSION +t_pfx=$PWD/trash/$model.$T-$RUBY_ENGINE-$RUBY_VERSION set -u PATH=$PWD/bin:$PATH diff --git a/t/test_isolate.rb b/t/test_isolate.rb index ca446c8..2adac31 100644 --- a/t/test_isolate.rb +++ b/t/test_isolate.rb @@ -1,7 +1,8 @@ require 'rubygems' require 'isolate' +engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' -path = "tmp/isolate/ruby-#{RUBY_VERSION}" +path = "tmp/isolate/#{engine}-#{RUBY_VERSION}" opts = { :system => false, # we want "ruby-1.8.7" and not "ruby-1.8", so disable multiruby @@ -16,23 +17,24 @@ Isolate.now!(opts) do gem 'rack', '1.1.0' gem 'unicorn', '0.991.0' - gem 'iobuffer', '0.1.3' - gem 'rev', '0.3.2' + if ! defined?(RUBY_ENGINE) + gem 'iobuffer', '0.1.3' + gem 'rev', '0.3.2' - gem 'eventmachine', '0.12.10' + gem 'eventmachine', '0.12.10' - gem 'sinatra', '0.9.4' - gem 'async_sinatra', '0.1.5' + gem 'sinatra', '0.9.4' + gem 'async_sinatra', '0.1.5' - gem 'neverblock', '0.1.6.2' + gem 'neverblock', '0.1.6.2' + gem 'cramp', '0.11' + end - if defined?(::Fiber) + if defined?(::Fiber) && ! defined?(RUBY_ENGINE) gem 'case', '0.5' gem 'revactor', '0.1.5' gem 'rack-fiber_pool', '0.9.0' end - - gem 'cramp', '0.11' end $stdout.reopen(old_out) -- cgit v1.2.3-24-ge0c7