unicorn 4.6.0pre1 - hijacking support
[unicorn.git] / t / GNUmakefile
blobbac50a67d40dffb30aa21d2eafdc26f122c96d29
1 # we can run tests in parallel with GNU make
2 all::
4 pid := $(shell echo $$PPID)
6 RUBY = ruby
7 RAKE = rake
8 -include ../local.mk
9 ifeq ($(RUBY_VERSION),)
10 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
11 endif
13 ifeq ($(RUBY_VERSION),)
14 $(error unable to detect RUBY_VERSION)
15 endif
17 RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
18 export RUBY_ENGINE
20 isolate_libs := ../tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION).mk
21 $(isolate_libs): ../script/isolate_for_tests
22 @cd .. && $(RUBY) script/isolate_for_tests
23 -include $(isolate_libs)
24 MYLIBS := $(RUBYLIB):$(ISOLATE_LIBS)
26 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
28 all:: $(T)
30 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
31 t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
32 TEST_OPTS =
33 # TRACER = strace -f -o $(t_pfx).strace -s 100000
34 # TRACER = /usr/bin/time -o $(t_pfx).time
36 ifdef V
37 ifeq ($(V),2)
38 TEST_OPTS += --trace
39 else
40 TEST_OPTS += --verbose
41 endif
42 endif
44 random_blob:
45 dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
46 mv $@.$(pid) $@
48 ssl-stamp:
49 ./sslgen.sh
50 > $@
52 $(T): random_blob ssl-stamp
54 dependencies := socat curl
55 deps := $(addprefix .dep+,$(dependencies))
56 $(deps): dep_bin = $(lastword $(subst +, ,$@))
57 $(deps):
58 @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
59 @test -s $@.$(pid) || \
60 { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
61 @mv $@.$(pid) $@
62 dep: $(deps)
64 test_prefix := $(CURDIR)/../test/$(RUBY_ENGINE)-$(RUBY_VERSION)
65 $(test_prefix)/.stamp:
66 $(MAKE) -C .. test-install
68 $(T): export RUBY := $(RUBY)
69 $(T): export RAKE := $(RAKE)
70 $(T): export PATH := $(test_prefix)/bin:$(PATH)
71 $(T): export RUBYLIB := $(test_prefix)/lib:$(MYLIBS)
72 $(T): dep $(test_prefix)/.stamp trash/.gitignore
73 $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS)
75 trash/.gitignore:
76 mkdir -p $(@D)
77 echo '*' > $@
79 clean:
80 $(RM) -r trash/*
82 .PHONY: $(T) clean