CTest: --tests-information does not support files without a newline character
When using the --tests-information
switch of ctest
with a file, if the file does not end with a newline, the last character will be ignored, which can result in ctest
not running a test, or running the wrong test. Example :
-
CMakeLists.txt
:
project(example)
cmake_minimum_required(VERSION 3.18)
enable_testing()
add_test(NAME test1 COMMAND true)
add_test(NAME test2 COMMAND true)
add_test(NAME test3 COMMAND true)
-
ctest
listing only test 1, when I expected to list tests 1 and 2:
[/tmp/ctest] $ mkdir build
[/tmp/ctest] $ cd build
[/tmp/ctest/build] $ cmake .. > /dev/null
[...]
[/tmp/ctest/build] $ echo -n 0,0,0,1,2 > tests-info.txt
[/tmp/ctest/build] $ ctest -N --tests-information tests-info.txt
Test project /tmp/ctest/build
Test #1: test1
Total Tests: 1
This behavior is surprising, and should be easy to avoid.
I believe this line looks suspicious.