From e3fe113f7886ce135dfb9505544db3b0df8e2ffd Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 25 Jan 2018 22:46:04 +0100
Subject: [PATCH] [CMake] Fixed error output when running ctest-targets.

---
 Jenkinsfile                             | 1 -
 scripts/cmake/test/AddTestTester.cmake  | 4 +++-
 scripts/cmake/test/AddTestWrapper.cmake | 6 ++++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index d3e3f4d9843..51e5b7b52da 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -407,7 +407,6 @@ pipeline {
           steps {
             script {
               configure { }
-              build { }
               build { target = 'ctest-large-serial' }
             }
           }
diff --git a/scripts/cmake/test/AddTestTester.cmake b/scripts/cmake/test/AddTestTester.cmake
index a77b1425278..2059f0f3743 100644
--- a/scripts/cmake/test/AddTestTester.cmake
+++ b/scripts/cmake/test/AddTestTester.cmake
@@ -36,6 +36,7 @@ foreach(CMD ${TESTER_COMMAND})
                 WORKING_DIRECTORY ${case_path}
                 RESULT_VARIABLE EXIT_CODE
                 OUTPUT_VARIABLE OUTPUT
+                ERROR_VARIABLE OUTPUT
             )
 
             if(NOT EXIT_CODE STREQUAL "0")
@@ -48,9 +49,10 @@ foreach(CMD ${TESTER_COMMAND})
             WORKING_DIRECTORY ${case_path}
             RESULT_VARIABLE EXIT_CODE
             OUTPUT_VARIABLE OUTPUT
+            ERROR_VARIABLE OUTPUT
         )
         if(NOT EXIT_CODE STREQUAL "0")
-            message(FATAL_ERROR "Error exit code: ${EXIT_CODE}")
+            message(FATAL_ERROR "Error exit code: ${EXIT_CODE}${OUTPUT}")
         endif()
     endif()
 endforeach()
diff --git a/scripts/cmake/test/AddTestWrapper.cmake b/scripts/cmake/test/AddTestWrapper.cmake
index 47cd6ac6f13..7c7f4098d4b 100644
--- a/scripts/cmake/test/AddTestWrapper.cmake
+++ b/scripts/cmake/test/AddTestWrapper.cmake
@@ -21,9 +21,11 @@ execute_process(
     COMMAND ${WRAPPER_COMMAND} ${WRAPPER_ARGS} ${EXECUTABLE} ${EXECUTABLE_ARGS}
     WORKING_DIRECTORY ${case_path}
     RESULT_VARIABLE EXIT_CODE
-    OUTPUT_FILE ${STDOUT_FILE_PATH}
+    # OUTPUT_FILE ${STDOUT_FILE_PATH} # must be used exclusively
+    OUTPUT_VARIABLE OUTPUT
+    ERROR_VARIABLE OUTPUT
 )
 
 if(NOT EXIT_CODE STREQUAL "0")
-    message(FATAL_ERROR "Test wrapper exited with code: ${EXIT_CODE}")
+    message(FATAL_ERROR "Test wrapper exited with code: ${EXIT_CODE}\n${OUTPUT}")
 endif()
-- 
GitLab