Merge pull request #504 from aaron-prindle/code-coverage

Working on adding test coverage monitoring
pull/505/head
dlorenc 2016-08-18 16:39:33 -07:00 committed by GitHub
commit f80ecf9263
3 changed files with 20 additions and 10 deletions

View File

@ -1,12 +1,10 @@
language: go
go:
- 1.6.3
go_import_path: k8s.io/minikube
# We shouldn't need to install anything because we use vendoring.
install:
- echo "Don't run anything."
# Run unit tests and linters.
script: make test
- echo "Don't run anything."
script:
- make test
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -1,6 +1,7 @@
# Minikube
[![Build Status](https://travis-ci.org/kubernetes/minikube.svg?branch=master)](https://travis-ci.org/kubernetes/minikube)
[![codecov](https://codecov.io/gh/aaron-prindle/minikube/branch/master/graph/badge.svg)](https://codecov.io/gh/aaron-prindle/minikube)
## What is Minikube?

17
test.sh
View File

@ -25,11 +25,22 @@ else
PYTHON="docker run --rm -it -v $(pwd):/minikube -w /minikube python python"
fi
# Run "go test" on packages that have test files.
COV_FILE=coverage.txt
COV_TMP_FILE=coverage_tmp.txt
# Run "go test" on packages that have test files. Also create coverage profile
echo "Running go tests..."
cd ${GOPATH}/src/${REPO_PATH}
TESTS=$(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...)
go test -v ${TESTS}
rm -f out/$COV_FILE
echo "mode: count" > out/$COV_FILE
for pkg in $(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...); do
go test -v $pkg -covermode=count -coverprofile=out/$COV_TMP_FILE
# tail -n +2 skips the first line of the file
# for coverprofile the first line is the `mode: count` line which we only want once in our file
tail -n +2 out/$COV_TMP_FILE >> out/$COV_FILE || (echo "Unable to append coverage for $pkg" && exit 1)
done
rm out/$COV_TMP_FILE
# Ignore these paths in the following tests.
ignore="vendor\|\_gopath\|assets.go"