Skip to content

Commit e3808de

Browse files
committed
Add integration tests
Signed-off-by: Knut Ahlers <knut@ahlers.me>
1 parent 48a288b commit e3808de

File tree

7 files changed

+1101
-1
lines changed

7 files changed

+1101
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ go:
44
- 1.6
55
- tip
66

7-
script: go test .
7+
script: make integration

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
SHARNESS_VERSION=v1.0.0
2+
13
publish:
24
curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh
35
bash golang.sh
6+
7+
update-sharness:
8+
curl -sSLo ./integration/sharness.sh https://cdn.rawgit.com/chriscool/sharness/$(SHARNESS_VERSION)/sharness.sh
9+
curl -sSLo ./integration/aggregate-results.sh https://cdn.rawgit.com/chriscool/sharness/$(SHARNESS_VERSION)/aggregate-results.sh
10+
curl -sSLo ./integration/Makefile https://cdn.rawgit.com/chriscool/sharness/$(SHARNESS_VERSION)/test/Makefile
11+
12+
test:
13+
go test .
14+
go vet .
15+
16+
integration: install
17+
cd integration && make all
18+
19+
install: test
20+
go install -a -ldflags="-X main.version=$(shell git describe --tags)"
21+
22+
.PHONY: integration

integration/Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Run tests
2+
#
3+
# Copyright (c) 2011-2012 Mathias Lafeldt
4+
# Copyright (c) 2005-2012 Git project
5+
# Copyright (c) 2005-2012 Junio C Hamano
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see http://www.gnu.org/licenses/ .
19+
20+
SHELL_PATH ?= $(SHELL)
21+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
22+
RM ?= rm -f
23+
PROVE ?= prove
24+
AGGREGATE_SCRIPT ?= aggregate-results.sh
25+
DEFAULT_TEST_TARGET ?= test
26+
27+
T = $(sort $(wildcard *.t))
28+
29+
all: $(DEFAULT_TEST_TARGET)
30+
31+
test: pre-clean
32+
$(MAKE) aggregate-results-and-cleanup
33+
34+
prove: pre-clean
35+
@echo "*** prove ***"; $(PROVE) --exec '$(SHELL_PATH_SQ)' $(PROVE_OPTS) $(T) :: $(TEST_OPTS)
36+
$(MAKE) clean-except-prove-cache
37+
38+
$(T):
39+
@echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(TEST_OPTS)
40+
41+
pre-clean:
42+
$(RM) -r test-results
43+
44+
clean-except-prove-cache:
45+
$(RM) -r 'trash directory'.* test-results
46+
47+
clean: clean-except-prove-cache
48+
$(RM) .prove
49+
50+
aggregate-results-and-cleanup: $(T)
51+
$(MAKE) aggregate-results
52+
$(MAKE) clean
53+
54+
aggregate-results:
55+
for f in test-results/*.counts; do \
56+
echo "$$f"; \
57+
done | '$(SHELL_PATH_SQ)' '$(AGGREGATE_SCRIPT)'
58+
59+
.PHONY: all test prove $(T) pre-clean clean
60+
.PHONY: aggregate-results-and-cleanup aggregate-results

integration/aggregate-results.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2008-2012 Git project
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 2 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see http://www.gnu.org/licenses/ .
17+
18+
failed_tests=
19+
fixed=0
20+
success=0
21+
failed=0
22+
broken=0
23+
total=0
24+
25+
while read file; do
26+
while read type value; do
27+
case $type in
28+
'')
29+
continue ;;
30+
fixed)
31+
fixed=$(($fixed + $value)) ;;
32+
success)
33+
success=$(($success + $value)) ;;
34+
failed)
35+
failed=$(($failed + $value))
36+
if test $value != 0; then
37+
test_name=$(expr "$file" : 'test-results/\(.*\)\.[0-9]*\.counts')
38+
failed_tests="$failed_tests $test_name"
39+
fi
40+
;;
41+
broken)
42+
broken=$(($broken + $value)) ;;
43+
total)
44+
total=$(($total + $value)) ;;
45+
esac
46+
done <"$file"
47+
done
48+
49+
if test -n "$failed_tests"; then
50+
printf "\nfailed test(s):$failed_tests\n\n"
51+
fi
52+
53+
printf "%-8s%d\n" fixed $fixed
54+
printf "%-8s%d\n" success $success
55+
printf "%-8s%d\n" failed $failed
56+
printf "%-8s%d\n" broken $broken
57+
printf "%-8s%d\n" total $total

0 commit comments

Comments
 (0)