Giter VIP home page Giter VIP logo

Comments (25)

matepek avatar matepek commented on June 6, 2024 2

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.

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024 1

Getting the environment variables from the custom program would be problematic though.

It is not impossible, but the whole concept is more "inheritance" like.
Please read my comments on this issue, also : https://en.wikipedia.org/wiki/Environment_variable

My conclusion: running a custom task won't be able to set the environment variables of the test executable --> Generate a wrapper.

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Users are usually creating a .bat/.sh wrapper for their executables.
If you are using a decent build tool, you can do it easily. For example in case of cmake: see. (edited)

My problem is that what kind of command are you thinking about? Linux, mac, windows? all?
You see hard to give a general solution. What I think I could do to call a vscode task but you might get the same result configuring a task with

"runOptions": {
        "runOn": "folderOpen"
},

Here is what I am using for similar purpose:

"tasks": [
    {
      "label": "createTmpWorkingFolder",
      "type": "shell",
      "command": "mkdir -p out/tmp/workspaceFolder",
      "windows": { "command": "mkdir out\\tmp\\workspaceFolder" }
    },
    {
      "type": "npm",
      "script": "watch",
      "problemMatcher": "$tsc-watch",
      "isBackground": true,
      "presentation": {
        "reveal": "never"
      },
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "runOptions": {
        "runOn": "folderOpen"
      },
      "dependsOn": ["createTmpWorkingFolder"]
    }
  ]

Note:

  • second task dependsOn first task
  • first task executes a different command on windows

See vscode task documentation for further details

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

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

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

like catch2TestExplorer.dependsOnTask: <taskname> where is a task defined in tasks.json.
That would be a nice solution don't you think?

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

Yes, that would be great!

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

You have to run it always before you run your exec, right?
What does actually do?
When do you have to rerun it?

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?

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

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

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

What is a batch? Not fully understand. Consecutive runs don't need to rerun the task?

FYI, you can modify the PATH environment variables.
with env: "env": { "PATH": "${os_env:PATH};<custom-path>" }
See details.

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

Ah, I think I misunderstood "batch", I thought of a command bash.
What we do on windows is:

  1. Open cmd
  2. Call activate script
  3. Run-Unit tests

I've seen the "env" option, but as the paths are changing, I cannot set a static value in the env-option

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Ah, in this case I think the catch2TestExplorer.dependsOnTask proposal wouldn't solve your problem.

Env modification is only available in the current process and it's children.

what you can do:

  • write a startvscode.bat like:
init.bat
code sourcefolder

or

  • generate executable wrappers as I mentioned previously.

I could develop this feature, but it wouldn't work for your scenario anyway.

from vscode-catch2-test-adapter.

vakokako avatar vakokako commented on June 6, 2024

Upvoting this issue. There is a need to source some dynamic environment variables, which cannot be done with "env": { ... }. So the ability to run a custom command before the executables run would be great!)

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

But wouldn‘t it be possible to run the test in a shell with:

  1. Open Shell
  2. Run custom script
  3. Run test
  4. Parse output

from vscode-catch2-test-adapter.

xahon avatar xahon commented on June 6, 2024

Why this issue is closed? I couldn't find a solution to rebuild project before testing

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

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:

Screenshot 2019-08-25 at 21 30 44

Anyway this issue is about running some custom command before the test.

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Hey @dkuschmierz and @friendnick ,

I created a cmake wrapper generator example.
You can check it here.

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

Now I understand what you ment. Works perfectly, thanks a lot!

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Happy to hear that.

Also, don't forget to replace catch2TestExplorer.executables pattern to a stricter one like "{build,Build,BUILD,out,Out,OUT}/**/*.test-wrapper*" because we don't want to match the executables just the wrappers.

from vscode-catch2-test-adapter.

dkuschmierz avatar dkuschmierz commented on June 6, 2024

Hi @matepek
any idea how to set up the debug configuration with this wrapper?

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

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.

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Hello @dkuschmierz ,
Just wondering that this second example was clear enough and solved your problem or not. ?

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Hello there will be a dependsOnTask under testMate.test.advancedExecutables in the next version (3.0.4)
With that one can run custom vscode command before the tests are run.

BUT it won't solve the environment variable issue: Additional variables under the execution of the task wont be propagated to the test executable.

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

I decided adding a new feature under testMate.advancedExecutables called envFile.
I think this is interesting for everyone who is reading this issue.
Check here

  "testMate.test.advancedExecutables": [{
    "pattern": "<default pattern>",
    "envFile": "out/env.json",
    "dependsOn": "out/env.json"
  }]

from vscode-catch2-test-adapter.

matepek avatar matepek commented on June 6, 2024

Added advancedExecutables.executionWrapper mostly for emulators.

from vscode-catch2-test-adapter.

umbi-umbi avatar umbi-umbi commented on June 6, 2024

kalie dificuldade waffa

from vscode-catch2-test-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.