-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to run command before tests? #116
Comments
Users are usually creating a .bat/.sh wrapper for their executables. My problem is that what kind of command are you thinking about? Linux, mac, windows? all?
Here is what I am using for similar purpose:
Note:
See vscode task documentation for further details |
Yes we also have a activation-script. For my other tasks I run that script before running e.g. the build command. But I don't have tasks for running/scanning the tests. My opinion is, that before running Mytest.exe another command should be called. In my case activate.bat from conan. Like a prerun command |
like |
Yes, that would be great! |
You have to run it always before you run your exec, right? Example: there is exec1 and exec2. Test runs in batches, so is it ok to run the task and then run exec1 and then exec2? |
It's only necessary once after opening the batches. So opening a batch, run the command once and afterwards run all tests would be fine. The script basically modifies the PATH variable and adds the necessary toolchain-folders temporarily |
What is a batch? Not fully understand. Consecutive runs don't need to rerun the task? FYI, you can modify the PATH environment variables. |
Ah, I think I misunderstood "batch", I thought of a command bash.
I've seen the "env" option, but as the paths are changing, I cannot set a static value in the env-option |
Ah, in this case I think the Env modification is only available in the current process and it's children. what you can do:
or
I could develop this feature, but it wouldn't work for your scenario anyway. |
Upvoting this issue. There is a need to source some dynamic environment variables, which cannot be done with |
Getting the environment variables from the custom program would be problematic though. It is not impossible, but the whole concept is more "inheritance" like. My conclusion: running a custom task won't be able to set the environment variables of the test executable --> Generate a wrapper. |
But wouldn‘t it be possible to run the test in a shell with:
|
Linux script? Mac script? (I know.. I meant the os specific programs) Windows script? You see, I could give a not so general solution. Instead this everybody can write their own wrapper scripts. More effective to generate those scripts. For example: in case of cmake check add_custom_command I guess I should write an example. Thumbs up if you would read it. |
Why this issue is closed? I couldn't find a solution to rebuild project before testing |
And you won't @xahon, This extension support the other way around. You rebuild your project and the extension detects the change and runs your 'changed' executables if autorun is set: Anyway this issue is about running some custom command before the test. |
Hey @dkuschmierz and @friendnick , I created a cmake wrapper generator example. |
Now I understand what you ment. Works perfectly, thanks a lot! |
Happy to hear that. Also, don't forget to replace |
Hi @matepek |
Hello @dkuschmierz , I'm afraid one cannot use debug feature with a wrapper. But.. there is another way to get the environment variables and just a slightly advanced. You can check the example here. |
Hello @dkuschmierz , |
Hello there will be a BUT it won't solve the environment variable issue: Additional variables under the execution of the task wont be propagated to the test executable. |
I decided adding a new feature under "testMate.test.advancedExecutables": [{
"pattern": "<default pattern>",
"envFile": "out/env.json",
"dependsOn": "out/env.json"
}]
|
Added |
kalie dificuldade waffa |
Describe the solution you'd like
I would like to have an option where I can set a command which is run before any test is run (before scanning, running, debugging etc.) Background is, that we set up our build environment with conan and I cannot run the tests if the build-environment is not set up properly. Therefore I currently have to start vscode via console and run the command before i run vscode.
The text was updated successfully, but these errors were encountered: