在调试单个测试时如何提供测试标志?

huangapple go评论89阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2021年10月27日 00:49:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/69727068.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定