From 97d554feb175179c7af70f7d61cf56886b3090bd Mon Sep 17 00:00:00 2001 From: glx22 Date: Sat, 9 Jan 2021 18:28:51 +0100 Subject: Codechange: On regression failure, output the result in a file --- cmake/scripts/Regression.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/scripts/Regression.cmake b/cmake/scripts/Regression.cmake index b38caed5c..620ed2c2c 100644 --- a/cmake/scripts/Regression.cmake +++ b/cmake/scripts/Regression.cmake @@ -74,23 +74,30 @@ list(LENGTH REGRESSION_EXPECTED REGRESSION_EXPECTED_LENGTH) # Compare the output foreach(RESULT IN LISTS REGRESSION_RESULT) - list(GET REGRESSION_EXPECTED ${ARGC} EXPECTED) + unset(EXPECTED) + if(ARGC LESS REGRESSION_EXPECTED_LENGTH) + list(GET REGRESSION_EXPECTED ${ARGC} EXPECTED) + endif() + + math(EXPR ARGC "${ARGC} + 1") if(NOT RESULT STREQUAL EXPECTED) message("${ARGC}: - ${EXPECTED}") message("${ARGC}: + ${RESULT}'") set(ERROR YES) endif() - - math(EXPR ARGC "${ARGC} + 1") endforeach() if(NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC) - math(EXPR MISSING "${REGRESSION_EXPECTED_LENGTH} - ${ARGC}") - message("(${MISSING} more lines were expected than found)") + message("(${REGRESSION_EXPECTED_LENGTH} lines were expected but ${ARGC} were found)") set(ERROR YES) endif() if(ERROR) - message(FATAL_ERROR "Regression failed") + # Ouput the regression result to a file + set(REGRESSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/regression_${REGRESSION_TEST}_output.txt") + string(REPLACE ";" "\n" REGRESSION_RESULT "${REGRESSION_RESULT}") + file(WRITE ${REGRESSION_FILE} "${REGRESSION_RESULT}") + + message(FATAL_ERROR "Regression failed - Output in ${REGRESSION_FILE}") endif() -- cgit v1.2.3-70-g09d2