bneumann / CppUTest-Test-Adapter

A test adapter for Visual Studio Code for the C/C++ Unit Test framework CppUTest.
MIT License
16 stars 7 forks source link

Multi-root Workspaces issue #40

Open fuchse-ego opened 1 year ago

fuchse-ego commented 1 year ago

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 :(

bneumann commented 1 year ago

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.

nische commented 1 year ago

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

nische commented 1 year ago

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,
    }
}
fuchse-ego commented 1 year ago

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];`
bneumann commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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