From 29b0c8c3606f07f3baee245138552c3c0256ded6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 5 Dec 2014 12:47:18 -0500 Subject: [PATCH] ctest --launch: write to cout and cerr in binary Because ctest reads in binary but writes in text mode, Windows' newline transformation can be applied multiple times causing '\n' in the source application to be written out as '\r\r\n' instead. --- Source/CTest/cmCTestLaunch.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index b65d23b8f..77c5d5785 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -21,6 +21,12 @@ #include #include +#ifdef _WIN32 +#include // for _setmode +#include // for _O_BINARY +#include // for std{out,err} and fileno +#endif + //---------------------------------------------------------------------------- cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv) { @@ -259,6 +265,13 @@ void cmCTestLaunch::RunChild() std::ios::out | std::ios::binary); } +#ifdef _WIN32 + // Do this so that newline transformation is not done when writing to cout + // and cerr below. + _setmode(fileno(stdout), _O_BINARY); + _setmode(fileno(stderr), _O_BINARY); +#endif + // Run the real command. cmsysProcess_Execute(cp);