golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.86k stars 741 forks source link

Add ability to customise test command #3340

Closed danhawkins closed 3 months ago

danhawkins commented 5 months ago

Is your feature request related to a problem? Please describe. In some cases, tests execute via a wrapper, some examples are encore.dev uses encore test and in this persons case the are using doppler, these wrappers are required for various reasons.

Describe the solution you'd like Just like there is an option to configure testFlags, it would be excellent to be able to specify testCcommand or similar, allowing the user control of the process called to execute tests, with the assumption that the called script / binary is compliant with the arguments being passed

Describe alternatives you've considered Right now, I'm running using https://github.com/cortesi/modd without IDE integration for tests that need the wrapper

Additional context N/A

hyangah commented 4 months ago

Since test logic shares a lot with the debug logic, can you help us understand how you want to wire these settings when debugging if tests require special setups done by wrappers? Thanks!

danhawkins commented 3 months ago

I'm not sure how debug would work, in my case the tool I am using doesn't support debug, so that's another problem I have to look into

However after speaking with another member in the encore.dev community, he suggested using alternateTools, this works for my use case, but doesn't support inline coverage markers, so I can look into that as a separate issue, but I think this issue can be closed using the approach from https://discord.com/channels/814482502336905216/1237684243606536293/1245754619141820428

workspace preferences

  "go.alternateTools": {
    "go": "${workspaceFolder}/test-script.sh"
  },

test-script.sh

#!/bin/sh

if [ $1 = 'test' ]
then
    encore $@ --no-color
else
    go $@
fi