summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2021-01-09 18:28:51 +0100
committerglx22 <glx22@users.noreply.github.com>2021-01-09 23:48:09 +0100
commit97d554feb175179c7af70f7d61cf56886b3090bd (patch)
treef5dca98aa2939f37a7d2798299c58f336512357b /cmake
parent5f1154e0765251dd0a88dc28dbe487080fdcd6e0 (diff)
downloadopenttd-97d554feb175179c7af70f7d61cf56886b3090bd.tar.xz
Codechange: On regression failure, output the result in a file
Diffstat (limited to 'cmake')
-rw-r--r--cmake/scripts/Regression.cmake19
1 files 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()