Skip to content

CTest: Fix --test-load regression

Brad King requested to merge brad.king/cmake:ctest-fix-test-load into master

The ctest --test-load option is implemented in StartNextTests by not starting any tests when the load is too high and instead sleeping and then returning. Prior to !1455 (merged) our outer loop in RunTests would immediately call StartNextTests again. However, now the uv_run loop may simply terminate if there are no tests running because no events are left pending.

Fix this by converting the sleep in StartNextTests into a libuv timer that it starts instead. This avoids leaving uv_run with no pending events. In the case that there are other running tests this also allows CTest to detect when they finish even if it during the wait period where we previously slept.

This regression was not caught by the test suite because the test only verified that we did not start the tests when the load was too high and not that it proceeded to start tests when the load dropped. Revise the test to cover both.

Fixes: #18338 (closed)

Merge request reports