Skip to content

Commit c9650f5

Browse files
committed
Merge pull request #34 from mboersma/add-coverage
feat(test-cover.sh): add go code coverage test script
2 parents 8fc3f90 + b2b1abc commit c9650f5

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: generic
33
services:
44
- docker
55

6-
script: make build
6+
script: make build test
77

88
deploy:
99
provider: script

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ IMAGE_PREFIX ?= deis
44
IMAGE := ${REGISTRY}${IMAGE_PREFIX}/go-dev:${VERSION}
55

66
# scripts are checked *after* build, so use paths inside the container
7-
SHELL_SCRIPTS = /usr/local/bin/gen-changelog.sh
7+
SHELL_SCRIPTS = /usr/local/bin/gen-changelog.sh /usr/local/bin/test-cover.sh
88

99
# dockerized development environment variables
1010
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ creating [issues][] and submitting [pull requests][].
1818
* [gox][]: simple go cross-compiling tool
1919
* [jq][]: command-line JSON processor
2020
* [shellcheck][]: static analysis for shell scripts
21+
* [test-cover.sh][]: test coverage for multiple go packages
2122
* [upx][]: executable packer
2223

2324
## Usage
@@ -60,4 +61,5 @@ The latest deis/go-dev Docker image is available at:
6061
[pull requests]: https://github.com/deis/docker-go-dev/pulls
6162
[Quay.io]: https://quay.io
6263
[shellcheck]: https://github.com/koalaman/shellcheck
64+
[test-cover.sh]: https://github.com/deis/docker-go-dev/tree/master/rootfs/usr/local/bin/test-cover.sh
6365
[upx]: http://upx.sourceforge.net/

rootfs/usr/local/bin/test-cover.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
6+
# shellcheck disable=SC2046
7+
pkgs=$(go list $(glide novendor))
8+
9+
echo "" > coverage.txt
10+
for p in $pkgs; do
11+
go test -covermode=atomic -coverprofile=profile.out "$p"
12+
if [ -s profile.out ]; then
13+
cat profile.out >> coverage.txt
14+
fi
15+
rm -f profile.out
16+
done

0 commit comments

Comments
 (0)