Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executionWrapper doesn't support having ${cmd} in path #441

Closed
5 tasks done
bwrsandman opened this issue Aug 7, 2024 · 1 comment
Closed
5 tasks done

executionWrapper doesn't support having ${cmd} in path #441

bwrsandman opened this issue Aug 7, 2024 · 1 comment
Labels
question Further information is requested

Comments

@bwrsandman
Copy link

bwrsandman commented Aug 7, 2024

Checklist

  • The issue is about this extension and NOT about a fork.
  • Checked the ALL the SUPPORT document.
  • The latest version of the extension was used.
  • It is not related to remote-vscode or I checked the following issue
  • Imagine yourself into my position and think how hard to debug the issue without insufficient information.
    I understand that you have privacy concerns and I expect you to understand that this extension is developed for free.
    Thanks.

Describe the bug

This is half a bug half feature request.
My usecase is this: I have an API that I test with GTest and multiple drivers that implement the api. The tests run against the API and not the drivers directly. I have gtest command line arguments but also I have --driver that gets piped into the initialization of the api.

The gtest runner in Visual Studio can do this with Additional test execution parameters.
Looking at the documentation, it seemed that executionWrapper could do this if I configured it like so:

"testMate.cpp.test.advancedExecutables": [
  {
    "name": "${filename} [driver=APPLE1]",
    "pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
    "executionWrapper": {
        "path": "${cmd}",
        "args": [ "${argsFlat}", "--driver", "APPLE1" ]
    }
  },
  {
    "name": "${filename} [driver=APPLE2]",
    "pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
    "executionWrapper": {
        "path": "${cmd}",
        "args": [ "${argsFlat}", "--driver", "APPLE2" ]
    }
  }
]

There are two issues as far as I can tell:

  1. The advanced executable shows up only once (if it were env, it would be twice).
  2. Running the executable does not send the driver.

I'm not very familiar with javascript but I tried debugging it and I found the following:

  1. There's a check in the spawner that looks for ${cmd} in the args. In this case it won't find it so it errors out. This is easily fixed by also checking path.
  2. Eventually, it will run path/to/${cmd} --help but it doesn't expand ${cmd} to the real value. I guess this can be fixed with a getter for the command.

Alternatives and why I can't use them

  • Using env: some of my drivers are on platforms that gtest supports but they don't support environment variables
  • Using a config file: Same as env, some patforms don't have filesystem support from gtest
  • Splitting off into one test per driver: This could work but it's a hassle and would make the project much more difficult to maintain.
  • Using a .bat/.sh file to inject the driver and then call the test. I tried this and it would work for making *Tests.bat files show up in the test explorer but when running I would get errors about command line length. Using a Tests.ps1 file would not show up in the explorer.

To Reproduce

  1. Go to settings.json
  2. Add an executionWrapper in testMate.cpp.test.advancedExecutables. The cmd must be in path and not in args. The most simple case would be this
    "executionWrapper": {
        "path": "${cmd}",
        "args": [ "${argsFlat}" ]
    }

Desktop

  • Extension Version: 4.12.0
  • VS Code Version: 1.92
  • Catch2 / Google Test / DOCTest Version: gtest from this repo
  • OS Type and Version: MacOSX, Windows 11
  • Using remote-ssh/docker/wsl? no

Logs

I did my best but setting testMate.cpp.log.logfile to /tmp/testMate.log and reloading the tests in test explorer did not create any files and testMate.cpp.log.logpanel does not add anything related to tests in the OUTPUT tab drop down menu.

@bwrsandman bwrsandman changed the title executionWrapper doesn't support having ${cmd} in path executionWrapper doesn't support having ${cmd} in path Aug 7, 2024
@matepek
Copy link
Owner

matepek commented Oct 19, 2024

Hey,

So you want extra parameter for your executable and you were trying to use executionWrapper for that. That's all or did I misunderstand something?

Have you noticed the prependTestRunningArgs and prependTestListingArgs features? Sound to me that these might be the droids you are looking for.

Let me know.

@matepek matepek added the question Further information is requested label Oct 19, 2024
@matepek matepek closed this as completed Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants