diff --git a/.travis.yml b/.travis.yml index 6e1f71b..334d70b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ install: - go get -v -t ./... script: - - make test + - make test-coverage after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 699e34a..769def5 100644 --- a/Makefile +++ b/Makefile @@ -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