1 # we can run tests in parallel with GNU make
5 pid
:= $(shell echo
$$PPID)
9 rainbows_lib
:= $(shell cd ..
/lib
&& pwd
)
11 ifeq ($(RUBY_VERSION
),)
12 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
15 ifeq ($(RUBY_VERSION
),)
16 $(error unable to detect RUBY_VERSION
)
19 RUBY_ENGINE
:= $(shell $(RUBY
) -e
'puts((RUBY_ENGINE rescue "ruby"))')
20 export RUBY_VERSION RUBY_ENGINE
22 ifeq (Linux
,$(shell uname
-s
))
24 models
+= XEpollThreadSpawn
25 models
+= XEpollThreadPool
28 models
+= WriterThreadPool
29 models
+= WriterThreadSpawn
33 models
+= StreamResponseEpoll
35 ifeq ($(RUBY_ENGINE
),ruby
)
37 ONENINE
:= $(shell case
$(RUBY_VERSION
) in
1.9.
*|
2.
*$(rp
) echo true
;;esac
)
38 ifeq ($(ONENINE
),true
)
39 ifeq ($(RUBY_VERSION
),1.9.2)
45 RUBY_LE_2_1
:= $(shell $(RUBY
) -e
'puts(RUBY_VERSION.to_f <= 2.1)')
46 ifeq ($(RUBY_LE_2_1
), true
)
48 models
+= CoolioThreadPool
49 models
+= CoolioThreadSpawn
50 models
+= CoolioFiberSpawn
51 models
+= EventMachine
57 ifeq ($(RUBY_ENGINE
),rbx
)
60 all_models
:= $(models
) Base
62 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
64 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
65 $(T
): MODELS
= $(models
)
67 # some tests can be run with all models
68 t0000-simple-http.sh
: MODELS
= $(all_models
)
69 t0001-unix-http.sh
: MODELS
= $(all_models
)
70 t0002-graceful.sh
: MODELS
= $(all_models
)
71 t0002-parser-error.sh
: MODELS
= $(all_models
)
72 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
74 # recursively run per-model tests
75 # haven't figured out a good way to make make non-recursive here, yet...
77 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
80 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
84 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
85 t_pfx
= trash
/$@
-$(RUBY_ENGINE
)-$(RUBY_VERSION
)
87 # TRACER = strace -f -o $(t_pfx).strace -s 100000
88 # TRACER = /usr/bin/time -o $(t_pfx).time
94 TEST_OPTS
+= --verbose
98 bindir := $(CURDIR
)/bin-
$(RUBY_ENGINE
)-$(RUBY_VERSION
)
99 bin_rainbows
:= $(bindir)/rainbows
100 $(bin_rainbows
): ruby_bin
= $(shell which
$(RUBY
))
101 $(bin_rainbows
): ..
/bin
/rainbows
103 install -m
755 $^
$@.
$(pid
)
104 $(MRI
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
108 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
111 dependencies
:= socat curl
112 deps
:= $(addprefix .dep
+,$(dependencies
))
113 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
115 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
116 @
test -s
$@.
$(pid
) || \
117 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
120 libs
:= tmp
/isolate
/$(RUBY_ENGINE
)-$(RUBY_VERSION
)/.libs
121 $(libs
): test_isolate.rb
125 t_deps
:= random_blob
$(libs
) $(deps
) $(bin_rainbows
) trash
/.gitignore
128 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
129 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
130 $(MODEL_T
): export RUBY
:= $(RUBY
)
131 $(MODEL_T
): export PATH
:= $(bindir):$(PATH
)
132 $(MODEL_T
): $(t_deps
)
133 RUBYLIB
=$(rainbows_lib
):$$(cat
$(libs
)):$(RUBYLIB
) \
134 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
141 $(RM
) -r trash
/*.log trash
/*.code
$(bindir)