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 ifeq ($(RUBY_VERSION
),1.9.1) # 1.9.2-preview1 was broken
25 all_models
:= $(models
) Base
27 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
29 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
30 $(T
): MODELS
= $(models
)
32 # some tests can be run with all models
33 t0000-simple-http.sh
: MODELS
= $(all_models
)
34 t0001-unix-http.sh
: MODELS
= $(all_models
)
35 t0002-graceful.sh
: MODELS
= $(all_models
)
36 t0002-parser-error.sh
: MODELS
= $(all_models
)
37 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
39 # this test is not compatible with non-Thread models yet
40 t9000-rack-app-pool.sh
: MODELS
= ThreadPool ThreadSpawn
42 # recursively run per-model tests
43 # haven't figured out a good way to make make non-recursive here, yet...
45 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
48 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
52 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
53 t_pfx
= trash
/$@
-$(RUBY_VERSION
)
55 # TRACER = strace -f -o $(t_pfx).strace -s 100000
56 # TRACER = /usr/bin/time -o $(t_pfx).time
62 TEST_OPTS
+= --verbose
66 test-bin-
$(RUBY_VERSION
)/rainbows
: ruby_bin
= $(shell which
$(RUBY
))
67 test-bin-
$(RUBY_VERSION
)/rainbows
: ..
/bin
/rainbows
69 install -m
755 $^
$@.
$(pid
)
70 $(RUBY
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
74 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
79 dependencies
:= socat curl
80 deps
:= $(addprefix .dep
+,$(dependencies
))
81 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
83 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
84 @
test -s
$@.
$(pid
) || \
85 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
89 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
90 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
91 $(MODEL_T
): trash
/.gitignore
92 $(MODEL_T
): export RUBY
:= $(RUBY
)
93 $(MODEL_T
): export PATH
:= $(CURDIR
)/test-bin-
$(RUBY_VERSION
):$(PATH
)
94 $(MODEL_T
): test-bin-
$(RUBY_VERSION
)/rainbows dep
95 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
102 $(RM
) -r trash
/*.log trash
/*.code test-bin-
$(RUBY_VERSION
)