0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 10:12:49 +01:00

Coverage reports for integration tests (#1960)

This commit is contained in:
Ethan Koenig 2017-06-15 05:38:33 -04:00 committed by Lunny Xiao
parent 033aaf4b38
commit 792cde7081
3 changed files with 25 additions and 5 deletions

View file

@ -46,6 +46,7 @@ pipeline:
GOPATH: /srv/app GOPATH: /srv/app
commands: commands:
- apk -U add openssh-client - apk -U add openssh-client
- go get github.com/wadey/gocovmerge
- make test-coverage - make test-coverage
when: when:
event: [ push ] event: [ push ]

2
.gitignore vendored
View file

@ -26,7 +26,7 @@ _testmain.go
*.test *.test
*.prof *.prof
coverage.out *coverage.out
/modules/options/bindata.go /modules/options/bindata.go
/modules/public/bindata.go /modules/public/bindata.go

View file

@ -107,7 +107,17 @@ test: fmt-check
go test $(PACKAGES) go test $(PACKAGES)
.PHONY: test-coverage .PHONY: test-coverage
test-coverage: test-coverage: unit-test-coverage integration-test-coverage
for PKG in $(PACKAGES); do\
touch $$GOPATH/src/$$PKG/coverage.out;\
egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\
gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\
mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\
rm int.coverage.out;\
done;
.PHONY: unit-test-coverage
unit-test-coverage:
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
.PHONY: test-vendor .PHONY: test-vendor
@ -124,9 +134,8 @@ test-vendor:
govendor status || exit 1 govendor status || exit 1
.PHONY: test-sqlite .PHONY: test-sqlite
test-sqlite: test-sqlite: integrations.sqlite.test
go test -c code.gitea.io/gitea/integrations -tags 'sqlite' GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.test
.PHONY: test-mysql .PHONY: test-mysql
test-mysql: integrations.test test-mysql: integrations.test
@ -136,9 +145,19 @@ test-mysql: integrations.test
test-pgsql: integrations.test test-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test
.PHONY: integration-test-coverage
integration-test-coverage: integrations.cover.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
integrations.test: $(SOURCES) integrations.test: $(SOURCES)
go test -c code.gitea.io/gitea/integrations go test -c code.gitea.io/gitea/integrations
integrations.sqlite.test: $(SOURCES)
go test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite'
integrations.cover.test: $(SOURCES)
go test -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
.PHONY: check .PHONY: check
check: test check: test