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
))
26 models
+= WriterThreadPool
27 models
+= WriterThreadSpawn
31 models
+= EventMachine
34 ifeq ($(RUBY_ENGINE
),ruby
)
36 ONENINE
:= $(shell case
$(RUBY_VERSION
) in
1.9.
*$(rp
) echo true
;;esac
)
37 ifeq ($(ONENINE
),true
)
41 models
+= CoolioThreadPool
42 models
+= CoolioThreadSpawn
43 models
+= CoolioFiberSpawn
47 ifeq ($(RUBY_ENGINE
),rbx
)
50 all_models
:= $(models
) Base
52 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
54 MODEL_T
:= $(foreach m
,$(all_models
),$(addprefix $(m
).
,$(T
)))
55 $(T
): MODELS
= $(models
)
57 # some tests can be run with all models
58 t0000-simple-http.sh
: MODELS
= $(all_models
)
59 t0001-unix-http.sh
: MODELS
= $(all_models
)
60 t0002-graceful.sh
: MODELS
= $(all_models
)
61 t0002-parser-error.sh
: MODELS
= $(all_models
)
62 t0003-reopen-logs.sh
: MODELS
= $(all_models
)
64 # recursively run per-model tests
65 # haven't figured out a good way to make make non-recursive here, yet...
67 $(MAKE
) $(foreach m
,$(MODELS
),$(addprefix $(m
).
,$@
))
70 $(MAKE
) $(filter $@.
%,$(MODEL_T
))
74 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
75 t_pfx
= trash
/$@
-$(RUBY_ENGINE
)-$(RUBY_VERSION
)
77 # TRACER = strace -f -o $(t_pfx).strace -s 100000
78 # TRACER = /usr/bin/time -o $(t_pfx).time
84 TEST_OPTS
+= --verbose
88 bindir := $(CURDIR
)/bin-
$(RUBY_ENGINE
)-$(RUBY_VERSION
)
89 bin_rainbows
:= $(bindir)/rainbows
90 $(bin_rainbows
): ruby_bin
= $(shell which
$(RUBY
))
91 $(bin_rainbows
): ..
/bin
/rainbows
93 install -m
755 $^
$@.
$(pid
)
94 $(MRI
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.
$(pid
)
98 dd if
=/dev
/urandom bs
=1M count
=30 of
=$@.
$(pid
)
103 dependencies
:= socat curl
104 deps
:= $(addprefix .dep
+,$(dependencies
))
105 $(deps
): dep_bin
= $(lastword
$(subst +, ,$@
))
107 @which
$(dep_bin
) > $@.
$(pid
) 2>/dev
/null ||
:
108 @
test -s
$@.
$(pid
) || \
109 { echo
>&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit
1; }
112 libs
:= tmp
/isolate
/$(RUBY_ENGINE
)-$(RUBY_VERSION
)/.libs
113 $(libs
): test_isolate.rb
117 t_deps
:= $(libs
) $(deps
) $(bin_rainbows
) trash
/.gitignore
120 $(MODEL_T
): export model
= $(firstword $(subst .
, ,$@
))
121 $(MODEL_T
): script
= $(subst $(model
).
,,$@
)
122 $(MODEL_T
): export RUBY
:= $(RUBY
)
123 $(MODEL_T
): export PATH
:= $(bindir):$(PATH
)
124 $(MODEL_T
): $(t_deps
)
125 RUBYLIB
=$(rainbows_lib
):$$(cat
$(libs
)):$(RUBYLIB
) \
126 $(TRACER
) $(SHELL
) $(SH_TEST_OPTS
) $(script
) $(TEST_OPTS
)
133 $(RM
) -r trash
/*.log trash
/*.code
$(bindir)