Skip to content

Commit 792cde7

Browse files
ethantkoeniglunny
authored andcommitted
Coverage reports for integration tests (#1960)
1 parent 033aaf4 commit 792cde7

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

.drone.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pipeline:
4646
GOPATH: /srv/app
4747
commands:
4848
- apk -U add openssh-client
49+
- go get github.com/wadey/gocovmerge
4950
- make test-coverage
5051
when:
5152
event: [ push ]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _testmain.go
2626
*.test
2727
*.prof
2828

29-
coverage.out
29+
*coverage.out
3030

3131
/modules/options/bindata.go
3232
/modules/public/bindata.go

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,17 @@ test: fmt-check
107107
go test $(PACKAGES)
108108

109109
.PHONY: test-coverage
110-
test-coverage:
110+
test-coverage: unit-test-coverage integration-test-coverage
111+
for PKG in $(PACKAGES); do\
112+
touch $$GOPATH/src/$$PKG/coverage.out;\
113+
egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\
114+
gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\
115+
mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\
116+
rm int.coverage.out;\
117+
done;
118+
119+
.PHONY: unit-test-coverage
120+
unit-test-coverage:
111121
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
112122

113123
.PHONY: test-vendor
@@ -124,9 +134,8 @@ test-vendor:
124134
govendor status || exit 1
125135

126136
.PHONY: test-sqlite
127-
test-sqlite:
128-
go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
129-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.test
137+
test-sqlite: integrations.sqlite.test
138+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
130139

131140
.PHONY: test-mysql
132141
test-mysql: integrations.test
@@ -136,9 +145,19 @@ test-mysql: integrations.test
136145
test-pgsql: integrations.test
137146
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test
138147

148+
.PHONY: integration-test-coverage
149+
integration-test-coverage: integrations.cover.test
150+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
151+
139152
integrations.test: $(SOURCES)
140153
go test -c code.gitea.io/gitea/integrations
141154

155+
integrations.sqlite.test: $(SOURCES)
156+
go test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite'
157+
158+
integrations.cover.test: $(SOURCES)
159+
go test -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
160+
142161
.PHONY: check
143162
check: test
144163

0 commit comments

Comments
 (0)