diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-04 16:38:08 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-04 18:38:32 -0700 |
commit | 903766ba0d278cb55d08e072c4c96c1d7f0dee8d (patch) | |
tree | 3f29a3aab6452c304043816c7c1c3c76f3009d8a /t/GNUmakefile | |
parent | 756c060f2992d35e30249688f1cfab8de9b4dfc1 (diff) | |
download | rainbows-903766ba0d278cb55d08e072c4c96c1d7f0dee8d.tar.gz |
I'd rather write shell scripts in shell than shell scripts in Ruby like was done with Unicorn. We're a *nix-only project so we'll embrace *nix tools to their fullest extent and as a pleasant side-effect these test cases are immune to internal API changes.
Diffstat (limited to 't/GNUmakefile')
-rw-r--r-- | t/GNUmakefile | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/t/GNUmakefile b/t/GNUmakefile new file mode 100644 index 0000000..1a95992 --- /dev/null +++ b/t/GNUmakefile @@ -0,0 +1,64 @@ +# we can run tests in parallel with GNU make + +all:: + +ruby = ruby +rainbows_lib := $(shell cd ../lib && pwd) +-include ../local.mk +ifeq ($(RUBY_VERSION),) + RUBY_VERSION := $(shell $(ruby) -e 'puts RUBY_VERSION') +endif + +ifeq ($(RUBYLIB),) + RUBYLIB := $(rainbows_lib) +else + RUBYLIB := $(rainbows_lib):$(RUBYLIB) +endif +export RUBYLIB + +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) + +all:: $(T) + +# can't rely on "set -o pipefail" since we don't require bash or ksh93 :< +t_code = $@-$(RUBY_VERSION).code +t_log = $@-$(RUBY_VERSION).log +t_run = $(TRACER) $(SHELL) $(TEST_OPTS) $@ + +# prefix stdout messages with ':', and stderr messages with '!' +t_wrap = ( ( ( $(RM) $(t_code); \ + $(t_run); \ + echo $$? > $(t_code) ) \ + | sed 's/^/$(pfx):/' 1>&3 ) 2>&1 \ + | sed 's/^/$(pfx)!/' 1>&2 ) 3>&1 + +ifndef V + quiet_pre = @echo '* $@'; + quiet_post = > $(t_log) 2>&1; exit $$(cat $(t_code)) + pfx = +else + quiet_pre = @echo '* $@'; + quiet_post = 2>&1 | tee $(t_log); exit $$(cat $(t_code)) + pfx = $@ +endif + +# TRACER='strace -f -o $@.strace -s 100000' +run_test = $(quiet_pre) ( $(t_wrap) ) $(quiet_post) + +test-bin-$(RUBY_VERSION)/rainbows: ruby_bin = $(shell which $(ruby)) +test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows + mkdir -p $(@D) + install -m 755 $^ $@+ + $(ruby) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@+ + cmp $@+ $@ || mv $@+ $@ + $(RM) $@+ + +$(T): export ruby := $(ruby) +$(T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH) +$(T): test-bin-$(RUBY_VERSION)/rainbows + $(run_test) + +clean: + $(RM) -r *.log *.code test-bin-$(RUBY_VERSION) + +.PHONY: $(T) clean |