diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-02-03 12:04:45 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-02-09 19:50:33 -0800 |
commit | 72a2aa7ca6e4ed1dab8448b93be31a35748ff881 (patch) | |
tree | 5835901566ef2a10d7ee4c76fe4f82d3852684e1 | |
parent | 9f9a9d488ed32a2891dc3dd7d50a17a16357042d (diff) | |
download | unicorn-72a2aa7ca6e4ed1dab8448b93be31a35748ff881.tar.gz |
Some of the tests here are horrifically slow due to sleeps, allow using gmake to run these tests in parallel. My Core2 Duo runs "make -j" over 10s faster than "rake".
-rw-r--r-- | GNUmakefile | 19 | ||||
-rw-r--r-- | test/test_helper.rb | 11 |
2 files changed, 27 insertions, 3 deletions
diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..457d30d --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,19 @@ +# use GNU Make to run tests in parallel, and without depending on Rubygems +all:: test + +slow_tests := test/unit/test_server.rb +awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}' +T := $(filter-out $(slow_tests),$(wildcard test/unit/test*.rb)) +T_n := $(shell $(awk_slow) $(slow_tests)) +test: $(T) $(T_n) + +$(slow_tests): + @$(MAKE) $(shell $(awk_slow) $@) +%.n: arg = $(subst .n,,$(subst --, -n ,$@)) +%.n: name = $(subst .n,,$(subst --, ,$@)) +%.n: + @echo '**** $(name) ****'; ruby -I lib $(arg) $(TEST_OPTS) +$(T): + @echo '**** $@ ****'; ruby -I lib $@ $(TEST_OPTS) + +.PHONY: $(T) $(slow_tests) diff --git a/test/test_helper.rb b/test/test_helper.rb index 7da26f8..ab97a9f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,7 +10,6 @@ HERE = File.dirname(__FILE__) unless defined?(HERE) $LOAD_PATH.unshift "#{HERE}/../#{dir}" end -require 'rubygems' require 'test/unit' require 'net/http' require 'timeout' @@ -21,6 +20,7 @@ require 'digest/sha1' require 'uri' require 'stringio' require 'pp' +require 'rubygems' require 'mongrel' @@ -32,8 +32,13 @@ end def redirect_test_io orig_err = STDERR.dup orig_out = STDOUT.dup - STDERR.reopen("test_stderr.log") - STDOUT.reopen("test_stdout.log") + STDERR.reopen("test_stderr.#{$$}.log") + STDOUT.reopen("test_stdout.#{$$}.log") + + at_exit do + File.unlink("test_stderr.#{$$}.log") rescue nil + File.unlink("test_stdout.#{$$}.log") rescue nil + end begin yield |