CppUTest-Test-Adapter icon indicating copy to clipboard operation
CppUTest-Test-Adapter copied to clipboard

Multi-root Workspaces issue

Open fuchse-ego opened this issue 2 years ago • 7 comments

Hi,

I'm using this extension in a single folder workspace and it's great!

However I experimented with the new Multi-root Workspaces and found that the test are not listed correctly. The tests will show up as "Main Suite" with no child nodes.

Steps to reproduce:

  1. Open folder with working tests.
  2. Add workspace folder (File -> Add folder to workspace)
  3. The tests are no longer available.

Unfortunately. I'm no JavaScript/TypeScript guy, so I cannot help you out with a PR :(

fuchse-ego avatar Oct 12 '22 09:10 fuchse-ego

Hi,

thanks for letting me know. I am sorry that I cannot investigate at the moment. I will look into it as soon as possible.

bneumann avatar Oct 16 '22 18:10 bneumann

@fuchse-ego Did you make it work with multiroot?

nische avatar Dec 12 '22 12:12 nische

Maybe somebody need this information:

After I specified the settings in the workspace settings, the testexplorer find the tests but add one "Main Suite" for each folder in Workspace. For me this will work at the Moment

Settings:

{
	"folders": [
		{
			"path": "CMake",
			"name": "Testrunner (local)"
		},
		{
			"path": "Core"
		},
		{
			"path": "Tests"
		}
	],
	"settings": {
		"todo-tree.tree.scanMode": "workspace only",
		"cmake.autoSelectActiveFolder": false,
		"cpputestTestAdapter.logpanel": true,
		"cpputestTestAdapter.testExecutable": "${workspaceFolder}/build/testrunner.exe",
		"cpputestTestAdapter.testExecutablePath": "${workspaceFolder}/build/",
		"testExplorer.hideWhen": "noAdapters",
		"testExplorer.useNativeTesting": false,
	}
}

nische avatar Dec 13 '22 14:12 nische

Hi @nische, thanks for this example. I also got it to work. However, as you mentioned, it duplicates all testes in as many "Main Suits" as you have workspace folders: image

Seems the bug here is that the test adapter only finds the test if specified in the workspace settings. It does not respect the individual .vscode/settings.json files in the workspace folders and the settings there.

Edit: I noticed that it only works, if the UnitTest folders is the first one in your workspace configuration. I'm no Java/TypeScript guy, but this line (main.ts#L8) seems suspicious:

	const workspaceFolder = (vscode.workspace.workspaceFolders || [])[0];`

fuchse-ego avatar Jan 03 '23 07:01 fuchse-ego

Nice find. Yes that line is very much suspicious and now that I read I can remember that I had some issues with that as well. From the back of my head I'd say it was due to the old extension. But since I am using the "new" test api anyways I think it is fixable

bneumann avatar Apr 14 '24 10:04 bneumann

I am currently over it and I am actually confused how you would set the test executable for multiple workspace because the setting itself only exists once. Best approach would be to add them all as a list and let the extension figure out which one exists. But then again, if you use {workspace} which one is it?

bneumann avatar Apr 14 '24 18:04 bneumann

To answer my own question: VSCode got you all covered, there is a folder setting as well. I will use that to let you configure the specific workspace testrunners:

grafik

bneumann avatar Apr 14 '24 18:04 bneumann