Add support for the ThreadSpawn concurrency model
[rainbows.git] / t / GNUmakefile
blob1a95992086a5032d25401506ea3c572a0e17e2bc
1 # we can run tests in parallel with GNU make
3 all::
5 ruby = ruby
6 rainbows_lib := $(shell cd ../lib && pwd)
7 -include ../local.mk
8 ifeq ($(RUBY_VERSION),)
9 RUBY_VERSION := $(shell $(ruby) -e 'puts RUBY_VERSION')
10 endif
12 ifeq ($(RUBYLIB),)
13 RUBYLIB := $(rainbows_lib)
14 else
15 RUBYLIB := $(rainbows_lib):$(RUBYLIB)
16 endif
17 export RUBYLIB
19 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
21 all:: $(T)
23 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
24 t_code = $@-$(RUBY_VERSION).code
25 t_log = $@-$(RUBY_VERSION).log
26 t_run = $(TRACER) $(SHELL) $(TEST_OPTS) $@
28 # prefix stdout messages with ':', and stderr messages with '!'
29 t_wrap = ( ( ( $(RM) $(t_code); \
30 $(t_run); \
31 echo $$? > $(t_code) ) \
32 | sed 's/^/$(pfx):/' 1>&3 ) 2>&1 \
33 | sed 's/^/$(pfx)!/' 1>&2 ) 3>&1
35 ifndef V
36 quiet_pre = @echo '* $@';
37 quiet_post = > $(t_log) 2>&1; exit $$(cat $(t_code))
38 pfx =
39 else
40 quiet_pre = @echo '* $@';
41 quiet_post = 2>&1 | tee $(t_log); exit $$(cat $(t_code))
42 pfx = $@
43 endif
45 # TRACER='strace -f -o $@.strace -s 100000'
46 run_test = $(quiet_pre) ( $(t_wrap) ) $(quiet_post)
48 test-bin-$(RUBY_VERSION)/rainbows: ruby_bin = $(shell which $(ruby))
49 test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows
50 mkdir -p $(@D)
51 install -m 755 $^ $@+
52 $(ruby) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@+
53 cmp $@+ $@ || mv $@+ $@
54 $(RM) $@+
56 $(T): export ruby := $(ruby)
57 $(T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH)
58 $(T): test-bin-$(RUBY_VERSION)/rainbows
59 $(run_test)
61 clean:
62 $(RM) -r *.log *.code test-bin-$(RUBY_VERSION)
64 .PHONY: $(T) clean