diff --git a/build/make/test-common.mk b/build/make/test-common.mk index 6eaa0da..efc0bc7 100644 --- a/build/make/test-common.mk +++ b/build/make/test-common.mk @@ -1,6 +1,6 @@ GO_JUNIT_REPORT=$(UTILITY_BIN_PATH)/go-junit-report -GO_JUNIT_REPORT_VERSION=v1.0.0 +GO_JUNIT_REPORT_VERSION=v2.1.0 $(GO_JUNIT_REPORT): $(UTILITY_BIN_PATH) @echo "Download go-junit-report..." - @$(call go-get-tool,$@,github.com/jstemmer/go-junit-report@$(GO_JUNIT_REPORT_VERSION)) + @$(call go-get-tool,$@,github.com/jstemmer/go-junit-report/v2@$(GO_JUNIT_REPORT_VERSION)) diff --git a/build/make/test-unit.mk b/build/make/test-unit.mk index 6838b1c..54a9448 100644 --- a/build/make/test-unit.mk +++ b/build/make/test-unit.mk @@ -1,6 +1,7 @@ ##@ Unit testing UNIT_TEST_DIR=$(TARGET_DIR)/unit-tests +XUNIT_JSON=$(UNIT_TEST_DIR)/report.json XUNIT_XML=$(UNIT_TEST_DIR)/unit-tests.xml UNIT_TEST_LOG=$(UNIT_TEST_DIR)/unit-tests.log COVERAGE_REPORT=$(UNIT_TEST_DIR)/coverage.out @@ -9,9 +10,9 @@ PRE_UNITTESTS?= POST_UNITTESTS?= .PHONY: unit-test -unit-test: $(XUNIT_XML) ## Start unit tests +unit-test: $(XUNIT_JSON) ## Start unit tests -$(XUNIT_XML): $(SRC) $(GO_JUNIT_REPORT) +$(XUNIT_JSON): $(SRC) $(GO_JUNIT_REPORT) ifneq ($(strip $(PRE_UNITTESTS)),) @make $(PRE_UNITTESTS) endif @@ -20,13 +21,15 @@ endif @echo 'mode: set' > ${COVERAGE_REPORT} @rm -f $(UNIT_TEST_LOG) || true @for PKG in $(PACKAGES) ; do \ - ${GO_CALL} test -v $$PKG -coverprofile=${COVERAGE_REPORT}.tmp 2>&1 | tee $(UNIT_TEST_LOG).tmp ; \ + ${GO_CALL} test -v $$PKG -coverprofile=${COVERAGE_REPORT}.tmp -json 2>&1 | tee $(UNIT_TEST_LOG).tmp ; \ cat ${COVERAGE_REPORT}.tmp | tail +2 >> ${COVERAGE_REPORT} ; \ rm -f ${COVERAGE_REPORT}.tmp ; \ cat $(UNIT_TEST_LOG).tmp >> $(UNIT_TEST_LOG) ; \ rm -f $(UNIT_TEST_LOG).tmp ; \ done - @cat $(UNIT_TEST_LOG) | $(GO_JUNIT_REPORT) > $@ + @cat $(UNIT_TEST_LOG) >> $@ + @cat $(UNIT_TEST_LOG) | $(GO_JUNIT_REPORT) -parser gojson > $(XUNIT_XML) + @if grep '^FAIL' $(UNIT_TEST_LOG); then \ exit 1; \ fi