golang / vscode-go

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

Go test profiling: run test with race detector #3269

Open firelizzard18 opened 3 months ago

firelizzard18 commented 3 months ago

Is your feature request related to a problem? Please describe. Interpreting the output of go test -race is somewhat cumbersome. It would be really nice if the extension's test support detected race warnings and displayed them somehow.

Describe the solution you'd like

  1. Provide a user action for running a test or tests with the race detector.
    • Option: When the user executes the "Go Test: Profile" context menu action on a test, add "Race detector" to the list of actions.
    • Option: A separate context menu action under "Go Test: Profile".
    • Option: A configuration option to always run tests with -race, or just reuse test flags.
  2. Run the test with -race.
  3. Parse the WARNING: DATA RACE sections out of the output.
  4. Present races to the user.
    • Option: Use the profile viewer: Add the test run as a "profile", with the races as children of it, and the write and previous write as children of each race.
    • Option: Can we reuse the diagnostics that are used for presenting error messages? This has the advantage of being integrated into vscode, showing the code location, and making it easy to show the full stack, but has the disadvantage of not clearly associating the two writes with each other (as in I can't think of a good way to do that).

Describe alternatives you've considered Using the race detector manually.

firelizzard18 commented 3 months ago

@hyangah This idea just popped into my head. Thoughts? The mechanical side - pulling the race warnings out of the output stream and parsing them - wouldn't be too difficult. It's the UX side where I'm kind of stuck.