Makefile: Add target to debug go tests in Delve
The Delve debugger allows you to debug tests using the dlv test
command. However, our Makefile sets a number required of build flags, so
running the delve command directly may fail to compile the test binary.
To allow easy debugging of tests, let's add a new debug-test-go
target
to apply our build process to dlv test
. There are two significant
differences between go test
and dlv test
:
- Only one package can be debugged at a time as each package's tests
are in a separate binary. If multiple packages are passed in
TEST_PACKAGES
then error 'cannot use -c flag with multiple packages' will be returned. - Test options, e.g.
-run
, must be passed todlv test
with atest.
prefix, e.g.-test.run
. We use apatsubst
onTEST_OPTIONS
to add the prefix.