Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change unittest-report generation from xml to json #195

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/make/test-common.mk
Original file line number Diff line number Diff line change
@@ -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))
11 changes: 7 additions & 4 deletions build/make/test-unit.mk
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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) >> $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to the GO_JUNIT_REPORT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've readded the go-junit-report part. To get the json output correct into the tool, i've had to upgrade the go-junit-report to 2.1.0 because the json parameter was added with v2

@cat $(UNIT_TEST_LOG) | $(GO_JUNIT_REPORT) -parser gojson > $(XUNIT_XML)

@if grep '^FAIL' $(UNIT_TEST_LOG); then \
exit 1; \
fi
Expand Down