ctest: --rerun-failed with multiple LastTestsFailed* files
I think something might be off in how the different files are checked (in order to retrieve the most recent one). In particular, after inserting a few print statements, I was able to see that, on my machine (RHEL7, gcc 8.2.0), the function cmSystemTools::FileTimeCompare
is not able to find the input file names. That appears to be because the input strings are just the file names, while the stat
function expects an absolute path to the file (the calls to stat return errno=2).
I tried to replace line 1874 in Source/CTest/cmCTestTestHandler.cxx
cmSystemTools::FileTimeCompare(logName, fileName, &res);
with
cmSystemTools::FileTimeCompare(prefix+logName, prefix+fileName, &res);
where prefix is the path from the directory struct (plus a "/"). With this modification, I can see that the correct LastTestsFailed* is picked up. I verified this by manually modifying an old one, to verify that ctest picks it up correctly (with the correct list of failed tests).
I'm not sure if the fix above is the correct one, or if the directory struct was supposed to hold absolute file names in the first place. Perhaps someone more experienced than me can chip in.
Note: I mainly use the v3.18.0 tag, but I verified the same issue (and same fix) is true also for current master (sha 628d7ef6).