[PATCH 58/90] run_test: show diff if test output does not match the expected output
authorAndreas Beckmann <anbe@debian.org>
Fri, 19 Nov 2021 11:10:45 +0000 (12:10 +0100)
committerAndreas Beckmann <anbe@debian.org>
Fri, 7 Jan 2022 23:55:22 +0000 (23:55 +0000)
Gbp-Pq: Name 0058-run_test-show-diff-if-test-output-does-not-match-the.patch

cmake/run_test.cmake

index 5ea265bbd32eedc833a8dae3b0738964b9cea0ae..41f13bf88b0a1b004c108a1ad3e6fd61c01ad4cd 100644 (file)
@@ -62,6 +62,16 @@ if(output_blessed)
     )
 
   if( test_not_successful )
+    find_program(DIFF "diff")
+    if(DIFF)
+      execute_process(
+        COMMAND "${DIFF}" "-d" "-u" "${output_blessed}" "${RANDOM_FILE}"
+        RESULT_VARIABLE test_not_successful
+        OUTPUT_VARIABLE stdout
+        ERROR_VARIABLE stderr
+        )
+      message("${stdout}\n${stderr}")
+    endif()
     message(SEND_ERROR "FAIL: Test output does not match the expected output; output stored in ${RANDOM_FILE}" )
   else()
     file(REMOVE "${RANDOM_FILE}")