-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add make
commands to standardize running/debugging Go tests
#24606
Conversation
test-go: dump-test-schema generate-mock | ||
go test -tags full,fts5,netgo ${GO_TEST_EXTRA_FLAGS_VAR} -parallel 8 -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/fleetdm/fleet/v4/... ./cmd/... ./ee/... ./orbit/pkg/... ./orbit/cmd/orbit ./pkg/... ./server/... ./tools/... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved a bunch of the boilerplate args into the base .run-go-tests
target; see updates test-go
target below
test-go: dump-test-schema generate-mock | ||
make .run-go-tests PKG_TO_TEST="./cmd/... ./ee/... ./orbit/pkg/... ./orbit/cmd/orbit ./pkg/... ./server/... ./tools/..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the $GO_TEST_EXTRA_FLAGS
var still works, so the existing make test-go
usage will be unaffected
@echo "Please specify one or more packages to debug with argument PKG_TO_TEST=\"/path/to/pkg/1 /path/to/pkg/2\"..."; | ||
else | ||
@echo Debugging tests with command: | ||
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like using the command line for dlv
, but I know some folks use vscode, do we want to add a launch.json entry to connect to this?
{
"name": "Launch Remote",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 61179,
"host": "localhost",
"cwd": "${workspaceFolder}",
"trace": "verbose"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Attach to a running Fleet server" is in the current launch.json. It doesn't have verbose logging on, but I'm not sure I'd want to unilaterally add that in case anyone's used to the way it works now. Although in my experience debugging go in VSCode is extremely slow so there might not be too many people using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I totally missed that entry 🤦 . I think "trace": "verbose" isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with these changes.
Checklist for submitter
Details
This PR adds two new user-facing
make
targets:run-go-tests
: run Go tests for one or more packages, optionally filtering to specific testsdebug-go-tests
: debug (using Delve) Go tests for one or more packages, optionally filtering to specific testsExample usage:
Notes
Two new "private" targets
.run-go-tests
and.debug-go-tests
were created as base commands for bothtest-go
(used in CI) and the new user-facing commands.