@@ -150,14 +150,30 @@ dump-test-schema:
150
150
# TESTS_TO_RUN: Name specific tests to run in the specified packages. Leave blank to run all tests in the specified packages.
151
151
# GO_TEST_EXTRA_FLAGS: Used to specify other arguments to `go test`.
152
152
# GO_TEST_MAKE_FLAGS: Internal var used by other targets to add arguments to `go test`.
153
- #
153
+ #
154
154
PKG_TO_TEST := "" # default to empty string; can be overridden on command line.
155
155
go_test_pkg_to_test := $(addprefix ./,$(PKG_TO_TEST ) ) # set paths for packages to test
156
156
dlv_test_pkg_to_test := $(addprefix github.com/fleetdm/fleet/v4/,$(PKG_TO_TEST ) ) # set URIs for packages to debug
157
157
158
+ DEFAULT_PKG_TO_TEST := ./cmd/... ./ee/... ./orbit/pkg/... ./orbit/cmd/orbit ./pkg/... ./server/... ./tools/...
159
+ ifeq ($(CI_TEST_PKG ) , main)
160
+ CI_PKG_TO_TEST=$(shell go list ${DEFAULT_PKG_TO_TEST} | grep -v "server/datastore/mysql" | grep -v "cmd/fleetctl" | grep -v "server/vulnerabilities" | sed -e 's|github.com/fleetdm/fleet/v4/||g')
161
+ else ifeq ($(CI_TEST_PKG), mysql)
162
+ CI_PKG_TO_TEST="server/datastore/mysql/..."
163
+ else ifeq ($(CI_TEST_PKG), fleetctl)
164
+ CI_PKG_TO_TEST="cmd/fleetctl/..."
165
+ else ifeq ($(CI_TEST_PKG), vuln)
166
+ CI_PKG_TO_TEST="server/vulnerabilities/..."
167
+ else
168
+ CI_PKG_TO_TEST=$(DEFAULT_PKG_TO_TEST)
169
+ endif
170
+
171
+ ci-pkg-list :
172
+ @echo $(CI_PKG_TO_TEST )
173
+
158
174
.run-go-tests :
159
175
ifeq ($(PKG_TO_TEST ) , "")
160
- @echo "Please specify one or more packages to test with argument PKG_TO_TEST=\"/path/to/pkg/1 /path/to/pkg/2\"...";
176
+ @echo "Please specify one or more packages to test with argument PKG_TO_TEST=\"/path/to/pkg/1 /path/to/pkg/2\"...";
161
177
else
162
178
@echo Running Go tests with command:
163
179
go test -tags full,fts5,netgo -run=${TESTS_TO_RUN} ${GO_TEST_MAKE_FLAGS} ${GO_TEST_EXTRA_FLAGS} -parallel 8 -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/fleetdm/fleet/v4/... $(go_test_pkg_to_test)
@@ -171,22 +187,22 @@ endif
171
187
# GO_TEST_EXTRA_FLAGS: Used to specify other arguments to `go test`.
172
188
.debug-go-tests :
173
189
ifeq ($(PKG_TO_TEST ) , "")
174
- @echo "Please specify one or more packages to debug with argument PKG_TO_TEST=\"/path/to/pkg/1 /path/to/pkg/2\"...";
190
+ @echo "Please specify one or more packages to debug with argument PKG_TO_TEST=\"/path/to/pkg/1 /path/to/pkg/2\"...";
175
191
else
176
192
@echo Debugging tests with command:
177
- dlv test ${dlv_test_pkg_to_test} --api-version=2 --listen=127.0.0.1:61179 ${DEBUG_TEST_EXTRA_FLAGS} -- -test.v -test.run=${TESTS_TO_RUN} ${GO_TEST_EXTRA_FLAGS}
193
+ dlv test ${dlv_test_pkg_to_test} --api-version=2 --listen=127.0.0.1:61179 ${DEBUG_TEST_EXTRA_FLAGS} -- -test.v -test.run=${TESTS_TO_RUN} ${GO_TEST_EXTRA_FLAGS}
178
194
endif
179
195
180
196
# Command to run specific tests in development. Can run all tests for one or more packages, or specific tests within packages.
181
197
run-go-tests :
182
198
@MYSQL_TEST=1 REDIS_TEST=1 MINIO_STORAGE_TEST=1 SAML_IDP_TEST=1 NETWORK_TEST=1 make .run-go-tests GO_TEST_MAKE_FLAGS=" -v"
183
199
184
200
debug-go-tests :
185
- @MYSQL_TEST=1 REDIS_TEST=1 MINIO_STORAGE_TEST=1 SAML_IDP_TEST=1 NETWORK_TEST=1 make .debug-go-tests
201
+ @MYSQL_TEST=1 REDIS_TEST=1 MINIO_STORAGE_TEST=1 SAML_IDP_TEST=1 NETWORK_TEST=1 make .debug-go-tests
186
202
187
203
# Command used in CI to run all tests.
188
- test-go : dump-test-schema generate-mock
189
- make .run-go-tests PKG_TO_TEST=" ./cmd/... ./ee/... ./orbit/pkg/... ./orbit/cmd/orbit ./pkg/... ./server/... ./tools/... "
204
+ test-go : dump-test-schema generate-mock
205
+ make .run-go-tests PKG_TO_TEST=" $( CI_PKG_TO_TEST ) "
190
206
191
207
analyze-go :
192
208
go test -tags full,fts5,netgo -race -cover ./...
0 commit comments