1 # we can run tests in parallel with GNU make
6 rainbows_lib
:= $(shell cd ..
/lib
&& pwd
)
8 ifeq ($(RUBY_VERSION
),)
9 RUBY_VERSION
:= $(shell $(ruby
) -e
'puts RUBY_VERSION')
13 RUBYLIB
:= $(rainbows_lib
)
15 RUBYLIB
:= $(rainbows_lib
):$(RUBYLIB
)
19 T
= $(wildcard t
[0-9][0-9][0-9][0-9]-*.sh
)
23 # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
24 t_code
= $@
-$(RUBY_VERSION
).code
25 t_log
= $@
-$(RUBY_VERSION
).log
26 t_run
= $(TRACER
) $(SHELL
) $(TEST_OPTS
) $@
28 # prefix stdout messages with ':', and stderr messages with '!'
29 t_wrap
= ( ( ( $(RM
) $(t_code
); \
31 echo
$$?
> $(t_code
) ) \
32 | sed
's/^/$(pfx):/' 1>&3 ) 2>&1 \
33 | sed
's/^/$(pfx)!/' 1>&2 ) 3>&1
36 quiet_pre
= @echo
'* $@';
37 quiet_post
= > $(t_log
) 2>&1; exit
$$(cat
$(t_code
))
40 quiet_pre
= @echo
'* $@';
41 quiet_post
= 2>&1 | tee
$(t_log
); exit
$$(cat
$(t_code
))
45 # TRACER='strace -f -o $@.strace -s 100000'
46 run_test
= $(quiet_pre
) ( $(t_wrap
) ) $(quiet_post
)
48 test-bin-
$(RUBY_VERSION
)/rainbows
: ruby_bin
= $(shell which
$(ruby
))
49 test-bin-
$(RUBY_VERSION
)/rainbows
: ..
/bin
/rainbows
52 $(ruby
) -i
-p
-e
'$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@
+
53 cmp
$@
+ $@ || mv
$@
+ $@
56 $(T
): export ruby
:= $(ruby
)
57 $(T
): export PATH
:= $(CURDIR
)/test-bin-
$(RUBY_VERSION
):$(PATH
)
58 $(T
): test-bin-
$(RUBY_VERSION
)/rainbows
62 $(RM
) -r
*.log
*.code test-bin-
$(RUBY_VERSION
)