Skip to content

Makefile: Add target to debug go tests in Delve

Will Chandler requested to merge wc-debug-makefile into master

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 to dlv test with a test. prefix, e.g. -test.run. We use a patsubst on TEST_OPTIONS to add the prefix.
Edited by Toon Claes

Merge request reports