ctest --show-only=json-v1 does not contain command when executables have not been built
The tests in ctest --show-only=json-v1
do not contain the commands when the executables have not been built (yet).
Consider this simple CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(ss C)
enable_testing()
file(WRITE run.c [[
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
]])
add_executable(run run.c)
add_test(run run arg1 arg2 arg3)
As usual, configure the project with CMake:
$ cmake -S . -B build
...
Then, run ctest --show-only=json-v1
to see what tests are gonna run.
Pipe the output through jq
to only show the tests.
$ cd build
$ ctest --show-only=json-v1 | jq .tests
[
{
"backtrace": 1,
"name": "run",
"properties": [
{
"name": "WORKING_DIRECTORY",
"value": "/tmp/ss/build"
}
]
}
]
Notice how the test(s) do not contain a command
key.
Build the project:
$ cmake --build .
...
And finally, run ctest --show-only=json-v1
again:
$ ctest --show-only=json-v1 | jq .tests
[
{
"backtrace": 1,
"command": [
"/tmp/ss/build/run",
"arg1",
"arg2",
"arg3"
],
"name": "run",
"properties": [
{
"name": "WORKING_DIRECTORY",
"value": "/tmp/ss/build"
}
]
}
]
Now, the generated json contains a command
.
I believe the command
key should be populated, even when nothing has been built.
Edited by Maarten