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
27 models
+= WriterThreadPool
28 models
+= WriterThreadSpawn
32 models
+= EventMachine
35 ifeq ($(RUBY_ENGINE
),ruby
)
37 ONENINE
:= $(shell case
$(RUBY_VERSION
) in
1.9.
*$(rp
) echo true
;;esac
)
38 ifeq ($(ONENINE
),true
)
39 ifeq ($(RUBY_VERSION
),1.9.2)
44 models
+= CoolioThreadPool
45 models
+= CoolioThreadSpawn
46 models
+= CoolioFiberSpawn
50 ifeq ($(RUBY_ENGINE
),rbx
)
53 all_models
:= $(models
) Base
55 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
57 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
58 $(T
): MODELS
= $(models
)
60 # some tests can be run with all models
61 t0000-simple-http.sh
: MODELS
= $(all_models
)
62 t0001-unix-http.sh
: MODELS
= $(all_models
)
63 t0002-graceful.sh
: MODELS
= $(all_models
)
64 t0002-parser-error.sh
: MODELS
= $(all_models
)
65 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
67 # recursively run per-model tests
68 # haven't figured out a good way to make make non-recursive here, yet...
70 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
73 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
77 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
78 t_pfx
= trash
/$@
-$(RUBY_ENGINE
)-$(RUBY_VERSION
)
80 # TRACER = strace -f -o $(t_pfx).strace -s 100000
81 # TRACER = /usr/bin/time -o $(t_pfx).time
87 TEST_OPTS
+= --verbose
91 bindir := $(CURDIR
)/bin-
$(RUBY_ENGINE
)-$(RUBY_VERSION
)
92 bin_rainbows
:= $(bindir)/rainbows
93 $(bin_rainbows
): ruby_bin
= $(shell which
$(RUBY
))
94 $(bin_rainbows
): ..
/bin
/rainbows
96 install -m
755 $^
$@.
$(pid
)
97 $(MRI
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
101 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
106 dependencies
:= socat curl
107 deps
:= $(addprefix .dep
+,$(dependencies
))
108 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
110 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
111 @
test -s
$@.
$(pid
) || \
112 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
115 libs
:= tmp
/isolate
/$(RUBY_ENGINE
)-$(RUBY_VERSION
)/.libs
116 $(libs
): test_isolate.rb
120 t_deps
:= $(libs
) $(deps
) $(bin_rainbows
) trash
/.gitignore
123 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
124 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
125 $(MODEL_T
): export RUBY
:= $(RUBY
)
126 $(MODEL_T
): export PATH
:= $(bindir):$(PATH
)
127 $(MODEL_T
): $(t_deps
)
128 RUBYLIB
=$(rainbows_lib
):$$(cat
$(libs
)):$(RUBYLIB
) \
129 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
136 $(RM
) -r trash
/*.log trash
/*.code
$(bindir)