test_upload: trap EPIPE if a connection shuts us down, too
[unicorn.git] / GNUmakefile
blob25f7527cf31f1ca34951f4bb1056d45c808f34a7
1 # use GNU Make to run tests in parallel, and without depending on Rubygems
2 all:: test
3 -include local.mk
4 ifeq ($(DLEXT),) # "so" for Linux
5 DLEXT := $(shell ruby -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
6 endif
8 slow_tests := test/unit/test_server.rb
9 awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}'
10 T := $(filter-out $(slow_tests),$(wildcard test/unit/test*.rb))
11 T_n := $(shell $(awk_slow) $(slow_tests))
12 t_log := $(subst .rb,.log,$(T)) $(subst .n,.log,$(T_n))
13 test: $(T) $(T_n)
14 @cat $(t_log) | ruby test/aggregate.rb
15 @$(RM) $(t_log)
17 $(slow_tests):
18 @$(MAKE) $(shell $(awk_slow) $@)
19 %.n: arg = $(subst .n,,$(subst --, -n ,$@))
20 %.n: name = $(subst .n,,$(subst --, ,$@))
21 %.n: t = $(subst .n,.log,$@)
22 %.n: lib/http11.$(DLEXT)
23 @echo '**** $(name) ****'; ruby -I lib $(arg) $(TEST_OPTS) >$(t)+ 2>&1
24 @mv $(t)+ $(t)
26 $(T): t = $(subst .rb,.log,$@)
27 $(T): lib/http11.$(DLEXT)
28 @echo '**** $@ ****'; ruby -I lib $@ $(TEST_OPTS) > $(t)+ 2>&1
29 @mv $(t)+ $(t)
31 http11_deps := $(addprefix ext/http11/, \
32 ext_help.h http11.c http11_parser.c http11_parser.h \
33 http11_parser.rl http11_parser_common.rl \
34 Makefile)
35 ext/http11/http11_parser.c: ext/http11/http11_parser.rl
36 cd $(@D) && ragel $(<F) -C -G2 -o $(@F)
37 ext/http11/Makefile: ext/http11/extconf.rb
38 cd $(@D) && ruby $(<F)
39 ext/http11/http11.$(DLEXT): $(http11_deps)
40 $(MAKE) -C $(@D)
41 lib/http11.$(DLEXT): ext/http11/http11.$(DLEXT)
42 @mkdir -p lib
43 install -m644 $< $@
45 clean:
46 -$(MAKE) -C ext/http11 clean
47 $(RM) ext/http11/Makefile lib/http11.$(DLEXT)
49 Manifest:
50 git ls-files > $@+
51 cmp $@+ $@ || mv $@+ $@
52 $(RM) -f $@+
54 .PHONY: $(T) $(slow_tests) Manifest