This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (63 loc) · 2.13 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Base directory
TWO = .
# Where are the source files for implementation
TARGETDIRS = examples/basic/
# Where are test files located
TESTDIRS = tests/
# All targets
all: basic
# Integration tests with h2spec
# `make h2spec` will run all h2spec tests
# against a local server
#
# `make <spec>` will run one of the specs
# in h2spec.conf against a local target
#
# NOTE: it does not work in OS X
H2SPEC_ALL = $(filter-out $(H2SPEC_SKIP), $(shell sed -e 's/\#.*$$//' -e "/^\s*$$/d" $(TWO)/h2spec.conf))
H2SPEC_TEST ?= $(H2SPEC_ALL)
# Port to use for h2spec tests
H2SPEC_PORT ?= 8888
.PHONY: h2spec-pre h2spec-post
h2spec-pre:
@rm -f summary.txt
@echo "------------------------------"
@echo "Integration tests with h2spec"
@echo "------------------------------"
h2spec-post:
@echo "------------------------------"
@awk '{printf "total: %d, passed: %d, failed: %d\n", $$1,$$1 - $$2,$$2}' summary.txt; \
FAILED=$$(awk '{print $$2}' summary.txt); \
rm summary.txt; \
test $$FAILED -eq 0
.PHONY: $(H2SPEC_ALL)
$(H2SPEC_ALL): /usr/local/bin/h2spec ./bin/basic
@if ! test -f summary.txt; then echo "0 0" > summary.txt; fi
@(./bin/basic $(H2SPEC_PORT) 2> server.log & echo $$! > server.pid) && sleep 0.3 && \
(h2spec $@ -p $(H2SPEC_PORT) > h2spec.log && rm h2spec.log); \
TOTAL=$$(awk '{print $$1 + 1}' summary.txt); \
FAILURES=$$(awk '{print $$2}' summary.txt); \
echo -n "$@: "; \
if test -e /proc/`cat server.pid`; then \
kill `cat server.pid`; \
if test -f h2spec.log; then \
echo "FAIL"; \
echo " Client output: "; \
FAILURES=$$(($$FAILURES + 1)); \
cat h2spec.log | sed -e/^Failures:/\{ -e:1 -en\;b1 -e\} -ed | grep -a -B 1 -A 4 "×" | sed /^$$/q; \
if test -s server.log; then echo " Server output:"; cat server.log | sed "s/^/ /"; fi; \
rm h2spec.log; \
else \
echo "PASS"; \
fi; \
else \
FAILURES=$$(($$FAILURES + 1)); \
echo "FAIL"; \
echo " Server output:"; cat server.log | sed "s/^/ /" ; \
fi; \
sleep 0.3; \
echo "$$TOTAL $$FAILURES" > summary.txt; \
rm server.pid server.log
# Run all target
h2spec: h2spec-pre $(H2SPEC_ALL) h2spec-post
include $(TWO)/Makefile.include