unicorn 1.1.5
[unicorn.git] / t / GNUmakefile
blobe80c43a4431ea6ec43441a6702eea456e7258e4d
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 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
22 all:: $(T)
24 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
25 t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
26 TEST_OPTS =
27 # TRACER = strace -f -o $(t_pfx).strace -s 100000
28 # TRACER = /usr/bin/time -o $(t_pfx).time
30 ifdef V
31 ifeq ($(V),2)
32 TEST_OPTS += --trace
33 else
34 TEST_OPTS += --verbose
35 endif
36 endif
38 random_blob:
39 dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
40 mv $@.$(pid) $@
42 $(T): random_blob
44 dependencies := socat curl
45 deps := $(addprefix .dep+,$(dependencies))
46 $(deps): dep_bin = $(lastword $(subst +, ,$@))
47 $(deps):
48 @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
49 @test -s $@.$(pid) || \
50 { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
51 @mv $@.$(pid) $@
52 dep: $(deps)
54 test_prefix := $(CURDIR)/../test/$(RUBY_ENGINE)-$(RUBY_VERSION)
55 $(test_prefix)/.stamp:
56 $(MAKE) -C .. test-install
58 $(T): export RUBY := $(RUBY)
59 $(T): export RAKE := $(RAKE)
60 $(T): export PATH := $(test_prefix)/bin:$(PATH)
61 $(T): export RUBYLIB := $(test_prefix)/lib:$(RUBYLIB)
62 $(T): dep $(test_prefix)/.stamp trash/.gitignore
63 $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS)
65 trash/.gitignore:
66 mkdir -p $(@D)
67 echo '*' > $@
69 clean:
70 $(RM) -r trash/*
72 .PHONY: $(T) clean