ctest: Allow arbitrary characters in test names of CTestCostData.txt
CTestCostData.txt tracks the number of runs and time of each test and stores the output in a simple file that contains just three things:
- test name
- number of times test has been run
- average cost (runtime) of the test
Each field is separated by a space character, and is parsed by splitting the input file on spaces and taking the first 3 parts. If a test name has a space in it, which is allowed by policy 0110 introduced in cmake 3.19, then parsing this file no longer works correctly.
This MR changes the way the lines are parsed such that it looks for spaces starting from the end and only looks for the first two. Once they are found, everything from the beginning of the line up to that second-to-last space is parsed as the test name. It no longer matters what characters appear in the test name (as long as it isn't a newline, which would still break this). Additionally, the parsing is more efficient since it no longer creates a vector and multiple strings for every line.
Fixes: #26594 (closed)