From d46db70179fd3ac19dbdb0862c886bb075cc02ee Mon Sep 17 00:00:00 2001 From: Isaac Garzon Date: Mon, 24 Oct 2022 21:33:49 +0300 Subject: [PATCH] cmake: clean up on successful runs and randomise test scheduling (#202) In the case where we create the test path, we should clean up after the run finishes as done in the Makefile, due to garbage that is left behind by tests and accumulates. While at it, randomise test scheduling in order to increase the likelihood of surfacing latent bugs that are hidden by the execution order. --- cmake/CTestRunner.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/CTestRunner.cmake b/cmake/CTestRunner.cmake index 3d90d6c58a..258da5db15 100644 --- a/cmake/CTestRunner.cmake +++ b/cmake/CTestRunner.cmake @@ -110,4 +110,9 @@ else() endif() # Run all tests, and show test output on failure -execute_process(COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --timeout ${test_timeout}) +execute_process(COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --schedule-random --timeout ${test_timeout} RESULT_VARIABLE rv) + +# Clean up after ourselves if the run was successful +if(DEFINED tmpdir AND DEFINED rv AND ${rv} EQUAL 0) + file(REMOVE_RECURSE ${tmpdir}) +endif()