tests: port all existing tests to TAP library
[rainbows.git] / t / GNUmakefile
blob24ce7504514fb227a4ba6132ac63812172781db5
1 # we can run tests in parallel with GNU make
3 all::
5 RUBY = $(ruby)
6 rainbows_lib := $(shell cd ../lib && pwd)
7 -include ../local.mk
8 ifeq ($(RUBY_VERSION),)
9 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
10 endif
12 ifeq ($(RUBYLIB),)
13 RUBYLIB := $(rainbows_lib)
14 else
15 RUBYLIB := $(rainbows_lib):$(RUBYLIB)
16 endif
17 export RUBYLIB RUBY_VERSION
19 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
21 all:: $(T)
23 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
24 t_pfx = trash/$@-$(RUBY_VERSION)
25 TEST_OPTS =
26 # TRACER = strace -f -o $(t_pfx).strace -s 100000
27 # TRACER = /usr/bin/time -o $(t_pfx).time
28 run_test = $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS)
30 ifdef V
31 ifeq ($(V),2)
32 TEST_OPTS += --trace
33 else
34 TEST_OPTS += --verbose
35 endif
36 endif
38 test-bin-$(RUBY_VERSION)/rainbows: ruby_bin = $(shell which $(RUBY))
39 test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows
40 mkdir -p $(@D)
41 install -m 755 $^ $@+
42 $(RUBY) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@+
43 mv $@+ $@
45 req_random_blob := $(wildcard t?1??-*.sh)
46 random_blob:
47 dd if=/dev/urandom bs=1M count=10 of=$@+
48 mv $@+ $@
50 $(req_random_blob): random_blob
52 $(T): trash/.gitignore
53 $(T): export RUBY := $(RUBY)
54 $(T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH)
55 $(T): test-bin-$(RUBY_VERSION)/rainbows
56 @$(run_test)
58 trash/.gitignore:
59 mkdir -p $(@D)
60 echo '*' > $@
62 clean:
63 $(RM) -r trash/*.log trash/*.code test-bin-$(RUBY_VERSION)
65 .PHONY: $(T) clean