-
Type: Story
-
Status: Resolved (View Workflow)
-
Priority: Medium
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: VOLTHA v2.2
-
Component/s: api-server
-
Labels:
-
Story Points:1
-
Epic Link:
The following doesn't work as it was intended:
GO_JUNIT_REPORT:=$(shell which go-junit-report) GOCOVER_COBERTURA:=$(shell which gocover-cobertura) test: ifeq (,$(GO_JUNIT_REPORT)) go get -u github.com/jstemmer/go-junit-report @GO_JUNIT_REPORT=$(GOPATH)/bin/go-junit-report endif ifeq (,$(GOCOVER_COBERTURA)) go get -u github.com/t-yuki/gocover-cobertura @GOCOVER_COBERTURA=$(GOPATH)/bin/gocover-cobertura endif @mkdir -p ./tests/results @go test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\ RETURN=$$? ;\ $(GO_JUNIT_REPORT) < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ $(GOCOVER_COBERTURA) < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ exit $$RETURN
For example, if go-junit-report is not installed when the Makefile is run, the go-test-results.out is zero bytes and the Makefile does not report an error.
I think this has something to do with scoping / evaluation of Makefile variables, which may not work as expected when set inside actions. The problem is `@GO_JUNIT_REPORT=$(GOPATH)/bin/go-junit-report` doesn't actually set GO_JUNIT_REPORT for subsequent commands.
To reproduce, `GO111MODULE=on go clean -i github.com/jstemmer/go-junit-report && make test && ls -al tests/results`