Closed johannes-fischer closed 11 months ago
When I change the executionWrapper
to
"executionWrapper": {
"path": "/bin/sh",
"args": [ "-c", "\"/home/fischer/ws/planner/devel_debug/setup.sh && ${cmd}\" ${argsStr} 2>&1" ]
}
I get a different behavior. I now sometimes get logs, but unreliably: I only see the logs in the output window early after a vs code restart, after some time the window vanishes from the drop-down list. Also, most of the restarts there are not logs at all. I attached the logs below. Moreover, the tests cannot be discovered (which seems to be indicated in the logs).
Now tried with bash:
"executionWrapper": {
"path": "/bin/bash",
"args": [ "-c", "\"source /home/fischer/ws/planner/devel_debug/setup.bash && ${cmd} ${argsStr} 2>&1\"" ]
}
I get the desired output when running this from a terminal directly:
/bin/bash -c "source /home/fischer/ws/planner/devel_debug/setup.bash && /home/fischer/ws/planner/devel_debug/.private/motionplanner_mpc_2d/lib/motionplanner_mpc_2d/motionplanner_mpc_2d-gtest-planner 2>&1"
I could obtain a log, but tests could not be discovered. I don't understand what this is telling me:
[2023-12-13 15:42:46.078] [DEBUG] Not a supported test executable {
spawner: s {
_executor: '/bin/bash',
_args: [
'-c',
'"source /home/fischer/ws/planner/devel_debug/setup.bash && ${cmd} ${argsStr} 2>&1"'
],
_cmdR: '${cmd}',
_argsR: '${args}',
_argsR2: '${argsFlat}',
_argsStrR: '${argsStr}'
},
execPath: '/home/fischer/ws/planner/devel_debug/.private/motionplanner_mpc_2d/lib/motionplanner_mpc_2d/motionplanner_mpc_2d-gtest-casadi',
stdout: '',
stderr: '/bin/bash: source /home/fischer/ws/planner/devel_debug/setup.bash && /home/fischer/ws/planner/devel_debug/.private/motionplanner_mpc_2d/lib/motionplanner_mpc_2d/motionplanner_mpc_2d-gtest-casadi --help 2>&1: No such file or directory\n'
}
Hello.
No such file or directory
is the error message.
I would recommend trying the envFile
approach. It is easier and less error prone.
Also your quotations doesn't seem right. try to remove the \"
Thanks for your advice, much appreciated!
The setup.sh
script is auto-generated by our software tooling, so I cannot replace it with a hand-written envFile
where I define the environment variables myself. Or is there a way how I can run a setup.sh
command in an envFile
? I could not find much online on envFile
's.
I will try it without the extra quotation marks. Just fyi: I took the quotation from your example here but maybe I misunderstood it.
quotation are around the ${cmd}
in the example
I know, I have tried different ways where to put them
try this
{
"version": "2.0.0",
"tasks": [
{
"label": "generate env file",
"type": "shell",
"command": "/bin/bash",
"args": [
"-c",
"source setup.sh && set > setup.env"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognised errors occur.
"reveal": "silent"
}
}
]
}
don't forget you need this as a task in the tasks.json
and has to add the task name like:
"testMate.cpp.test.advancedExecutables": [
{
"pattern": "...",
"envFile": "setup.env",
"runTask": {
"before": [ "generate env file" ]
}
}
]
Furthermore one can fine tune the generate env file
task to run only if necessary like
/bin/bash -c "if test ! -f setup.env; then source setup.sh && set > setup.env; fi"
Test command is quite extensive, you can do a lot of magic here to make your workflow faster
Checklist
Describe the bug
I need to execute a shell script before running tests to set up the environment. I went through the documentation and all old issues but I cannot figure out how to achieve this. I tried to do use
executionWrapper
, but I may be using it wrongly. When I runin a terminal it works as expected (where
./devel_debug/lib/motionplanner_mpc_2d/motionplanner_mpc_2d-gtest-planner
is a test executable). I also have set up the extension to run the test from vs code, but then they of course run without thesetup.sh
before. So I tried adding this to the test execution config:The result is that the extension tried to discover tests for a very long time (1-2 minutes) and then either does not even discover the tests anymore (I did not change anything in the
pattern
, only added theexecutionWrapper
) or if it discovers them I don't see the effect of the set up script.To Reproduce
Not sure, how this can be reproduced on a different machine.
Desktop
**Log** (optional but recommended)
Unfortunately, I don't see any logs, I also have the issue https://github.com/matepek/vscode-catch2-test-adapter/issues/383