1 # we can run tests in parallel with GNU make
5 pid
:= $(shell echo
$$PPID)
8 rainbows_lib
:= $(shell cd ..
/lib
&& pwd
)
10 ifeq ($(RUBY_VERSION
),)
11 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
15 RUBYLIB
:= $(rainbows_lib
)
17 RUBYLIB
:= $(rainbows_lib
):$(RUBYLIB
)
19 export RUBYLIB RUBY_VERSION
21 models
:= ThreadPool ThreadSpawn Rev EventMachine
22 models
+= RevThreadSpawn
23 ifeq ($(RUBY_VERSION
),1.9.1) # 1.9.2-preview1 was broken
26 all_models
:= $(models
) Base
28 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
30 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
31 $(T
): MODELS
= $(models
)
33 # some tests can be run with all models
34 t0000-simple-http.sh
: MODELS
= $(all_models
)
35 t0001-unix-http.sh
: MODELS
= $(all_models
)
36 t0002-graceful.sh
: MODELS
= $(all_models
)
37 t0002-parser-error.sh
: MODELS
= $(all_models
)
38 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
40 # this test is not compatible with non-Thread models yet
41 t9000-rack-app-pool.sh
: MODELS
= ThreadPool ThreadSpawn
43 # recursively run per-model tests
44 # haven't figured out a good way to make make non-recursive here, yet...
46 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
49 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
53 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
54 t_pfx
= trash
/$@
-$(RUBY_VERSION
)
56 # TRACER = strace -f -o $(t_pfx).strace -s 100000
57 # TRACER = /usr/bin/time -o $(t_pfx).time
63 TEST_OPTS
+= --verbose
67 test-bin-
$(RUBY_VERSION
)/rainbows
: ruby_bin
= $(shell which
$(RUBY
))
68 test-bin-
$(RUBY_VERSION
)/rainbows
: ..
/bin
/rainbows
70 install -m
755 $^
$@.
$(pid
)
71 $(RUBY
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
75 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
80 dependencies
:= socat curl
81 deps
:= $(addprefix .dep
+,$(dependencies
))
82 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
84 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
85 @
test -s
$@.
$(pid
) || \
86 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
90 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
91 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
92 $(MODEL_T
): trash
/.gitignore
93 $(MODEL_T
): export RUBY
:= $(RUBY
)
94 $(MODEL_T
): export PATH
:= $(CURDIR
)/test-bin-
$(RUBY_VERSION
):$(PATH
)
95 $(MODEL_T
): test-bin-
$(RUBY_VERSION
)/rainbows dep
96 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
103 $(RM
) -r trash
/*.log trash
/*.code test-bin-
$(RUBY_VERSION
)