Added test-coverage

This commit is contained in:
David Paz
2017-06-27 10:42:46 +02:00
committed by Santiago M. Mola
parent 7e827e47ef
commit ded3e2c4ae
2 changed files with 18 additions and 1 deletions

View File

@ -16,7 +16,7 @@ install:
- go get -v -t ./...
script:
- make test
- make test-coverage
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -1,3 +1,7 @@
COVERAGE_REPORT := coverage.txt
COVERAGE_PROFILE := profile.out
COVERAGE_MODE := atomic
LINGUIST_PATH = .linguist
$(LINGUIST_PATH):
@ -6,6 +10,19 @@ $(LINGUIST_PATH):
test: $(LINGUIST_PATH)
go test -v ./...
test-coverage: $(LINGUIST_PATH)
@echo "mode: $(COVERAGE_MODE)" > $(COVERAGE_REPORT); \
for dir in `find . -name "*.go" | grep -o '.*/' | sort -u | grep -v './fixtures/' | grep -v './.linguist/'`; do \
go test $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \
if [ $$? != 0 ]; then \
exit 2; \
fi; \
if [ -f $(COVERAGE_PROFILE) ]; then \
tail -n +2 $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \
rm $(COVERAGE_PROFILE); \
fi; \
done;
code-generate: $(LINGUIST_PATH)
mkdir -p data
go run internal/code-generator/main.go