Index: CWineTest.cpp =================================================================== --- modules/rostests/rosautotest/CWineTest.cpp (revision 68236) +++ modules/rostests/rosautotest/CWineTest.cpp (working copy) @@ -276,6 +276,7 @@ stringstream ss, ssFinish; DWORD StartTime; float TotalTime; + string tailString; CPipe Pipe; char Buffer[1024]; @@ -294,7 +295,7 @@ { /* Output text through StringOut, even while the test is still running */ Buffer[BytesAvailable] = 0; - StringOut(string(Buffer)); + tailString = StringOut(tailString.append(string(Buffer)), false); if(Configuration.DoSubmit()) TestInfo->Log += Buffer; @@ -304,10 +305,17 @@ } catch(CTestException& e) { + if(!tailString.empty()) + StringOut(tailString); + tailString.clear(); StringOut(e.GetMessage()); TestInfo->Log += e.GetMessage(); } + /* Print what's left */ + if(!tailString.empty()) + StringOut(tailString); + TotalTime = ((float)GetTickCount() - StartTime)/1000; ssFinish << "Test " << TestInfo->Test << " completed in "; ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl; Index: precomp.h =================================================================== --- modules/rostests/rosautotest/precomp.h (revision 68236) +++ modules/rostests/rosautotest/precomp.h (working copy) @@ -69,7 +69,7 @@ string EscapeString(const string& Input); string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName); bool IsNumber(const char* Input); -void StringOut(const string& InputString); +string StringOut(const string& InputString, bool forcePrint = true); string UnicodeToAscii(PCWSTR UnicodeString); string UnicodeToAscii(const wstring& UnicodeString); Index: tools.cpp =================================================================== --- modules/rostests/rosautotest/tools.cpp (revision 68236) +++ modules/rostests/rosautotest/tools.cpp (working copy) @@ -90,19 +90,27 @@ * * @param InputString * The std::string to output + * + * @param forcePrint + * true to output the whole input string, false to only print full lines + * + * @return + * if forcePrint is false, the part of the input string after the last newline, empty string otherwise */ -void -StringOut(const string& InputString) +string +StringOut(const string& InputString, bool forcePrint) { const char* pInput = InputString.c_str(); char* OutputString = new char[InputString.size() + 1]; char* pOutput = OutputString; + char* pLastNewline = pOutput; + string TailString; /* Unify the line endings (the piped output of the tests may use CRLF) */ - while (*pInput) + while(*pInput) { /* If this is a CRLF line-ending, only copy a \n to the new string and skip the next character */ - if (*pInput == '\r' && *(pInput + 1) == '\n') + if(*pInput == '\r' && *(pInput + 1) == '\n') { *pOutput = '\n'; ++pInput; @@ -112,17 +120,26 @@ *pOutput = *pInput; } + if(*pOutput == '\n') + pLastNewline = pOutput; + ++pInput; ++pOutput; } *pOutput = 0; + if(!forcePrint && pLastNewline != pOutput - 1) + { + TailString = string(pLastNewline + 1); + pLastNewline[1] = 0; + } OutputDebugStringA(OutputString); - if (Configuration.DoPrint()) + if(Configuration.DoPrint()) cout << OutputString << flush; delete[] OutputString; + return TailString; } /**