Skip to content

Commit 8b7e442

Browse files
Danielius1922Daniel Adam
authored andcommitted
Use all packages for coverage analysis
1 parent ac43daa commit 8b7e442

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,32 @@ endef
133133

134134
DIRECTORIES:=$(shell ls -d ./*/)
135135

136+
define RUN-TESTS
137+
echo "Executing tests"; \
138+
START_TIME=$$(date +%s); \
139+
COVERAGE_FILE=/coverage/hub.coverage.txt ; \
140+
JSON_REPORT_FILE=$(WORKING_DIRECTORY)/.tmp/report/hub.report.json ; \
141+
if [ -n "$${JSON_REPORT}" ]; then \
142+
$(call RUN-DOCKER, go test -timeout=45m -race -p 1 -v ./... -coverpkg=./... -covermode=atomic -coverprofile=$${COVERAGE_FILE} -json > "$${JSON_REPORT_FILE}") \
143+
else \
144+
$(call RUN-DOCKER, go test -timeout=45m -race -p 1 -v ./... -coverpkg=./... -covermode=atomic -coverprofile=$${COVERAGE_FILE}) \
145+
fi ; \
146+
EXIT_STATUS=$$? ; \
147+
if [ $${EXIT_STATUS} -ne 0 ]; then \
148+
exit $${EXIT_STATUS}; \
149+
fi ; \
150+
STOP_TIME=$$(date +%s) ; \
151+
EXECUTION_TIME=$$((STOP_TIME-START_TIME)) ; \
152+
echo "" ; \
153+
echo "Execution time: $${EXECUTION_TIME} seconds" ; \
154+
echo "" ;
155+
endef
156+
136157
test: env
137158
@mkdir -p $(WORKING_DIRECTORY)/.tmp/home
138159
@mkdir -p $(WORKING_DIRECTORY)/.tmp/home/certificate-authority
139160
@mkdir -p $(WORKING_DIRECTORY)/.tmp/report
140-
@for DIRECTORY in $(DIRECTORIES); do \
141-
if ! go list -f '{{.GoFiles}}' $$DIRECTORY... 2>/dev/null | grep go > /dev/null 2>&1; then \
142-
echo "No golang files detected, directory $${DIRECTORY} skipped"; \
143-
continue ; \
144-
fi ; \
145-
$(call RUN-TESTS-IN-DIRECTORY,$$DIRECTORY) \
146-
done
161+
@$(call RUN-TESTS)
147162

148163
test-targets := $(addprefix test-,$(patsubst ./%/,%,$(DIRECTORIES)))
149164

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ sonar.test.exclusions=
2121
#sonar.go.tests.reportPaths=.tmp/report/certificate-authority.report.json,.tmp/report/cloud2cloud-connector.report.json,.tmp/report/cloud2cloud-gateway.report.json,.tmp/report/coap-gateway.report.json,.tmp/report/grpc-gateway.report.json,.tmp/report/http-gateway.report.json,.tmp/report/identity-store.report.json,.tmp/report/resource-aggregate.report.json,.tmp/report/resource-directory.report.json
2222

2323
sonar.go.coverage.reportPaths=.tmp/coverage/*.coverage.txt
24-
sonar.coverage.exclusions=bundle/*,charts/*,http-gateway/grpc-websocket/*,http-gateway/grpc-websocket/web/*,**/*.pb.go,**/*.pb.gw.go,**/*.js,**/*.py
24+
sonar.coverage.exclusions=bundle/*,charts/*,http-gateway/grpc-websocket/*,http-gateway/grpc-websocket/web/*,**/main.go,**/*.pb.go,**/*.pb.gw.go,**/*.js,**/*.py

0 commit comments

Comments
 (0)