英文:
How to provide test flags when debugging a single test?
问题
当使用“Go: Debug Test at Cursor”功能调试单个测试时,我该如何传递测试标志(例如-test.v和-test.vet=off标志)给测试程序?
工作区设置中的go.testFlags部分也包含这些设置,但似乎只在运行测试(Go: Run Test at Cursor)时才起作用。
我正在使用Visual Studio Code 1.61.2,vscode-go v0.28.1和自动安装的dlv-dap。
英文:
How can I pass test flags (e.g. the -test.v and -test.vet=off flags) to the test program when debugging a single test, i.e. when I use the Go: Debug Test at Cursor functionality?
The go.testFlags section from the workspace settings contains these settings, too - but it seems that they only have an effect when running the test (Go: Run Test at Cursor).
I am using Visual Studio Code 1.61.2, vscode-go v0.28.1, and the dlv-dap that is auto-installed.
答案1
得分: 1
问题可能出在 src/goTest.ts#_testAtCursor()。
if (cmd === 'debug') {
return debugTestAtCursor(editor, testFunctionName, testFunctions, goConfig);
} else if (cmd === 'benchmark' || cmd === 'test') {
return runTestAtCursor(editor, testFunctionName, testFunctions, goConfig, cmd, args);
} else {
throw new Error(`Unsupported command: ${cmd}`);
}
在调用 debugTestAtCursor() 时没有 cmd, args,与 runTestAtCursor() 不同。
这可能意味着当前实现不支持此功能。
英文:
The issue might come from src/goTest.ts#_testAtCursor()
if (cmd === 'debug') {
return debugTestAtCursor(editor, testFunctionName, testFunctions, goConfig);
} else if (cmd === 'benchmark' || cmd === 'test') {
return runTestAtCursor(editor, testFunctionName, testFunctions, goConfig, cmd, args);
} else {
throw new Error(`Unsupported command: ${cmd}`);
}
There is no cmd, args when calling debugTestAtCursor(), as opposed to runTestAtCursor().
That could mean this is not supported in the current implementation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论