CMake: Fix exit code to be shown properly on test failure

The result variable was expanded at configure time rather than at
script execution time due to missing escaping.

A tidbit of information, the result variable can contain not only an
exit code, but a string as well.
For example on arm macOS with a crashed test it contains
'SIGTRAP'.

Curiously if the crashing executable is executed directly without
CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of
the shell.

Amends 3ef6af024be43bc18352796df61542a241192583

Pick-to: 6.2 6.3
Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Alexandru Croitor 2021-12-17 13:30:39 +01:00
parent 2fef4636aa
commit 340b2a1a47

View File

@ -577,7 +577,7 @@ execute_process(COMMAND ${extra_runner} ${arg_COMMAND}
${post_run}
if(NOT result EQUAL 0)
string(JOIN \" \" full_command ${arg_COMMAND})
message(FATAL_ERROR \"\${full_command} execution failed with exit code ${result}.\")
message(FATAL_ERROR \"\${full_command} execution failed with exit code \${result}.\")
endif()"
)
endfunction()