- Continue the testing process in case a test fails to execute
ONLINE-441
svn path=/trunk/; revision=66504
wcscpy(CommandLinePtr, CommandLine.c_str());
if(!CreateProcessW(NULL, CommandLinePtr, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo))
wcscpy(CommandLinePtr, CommandLine.c_str());
if(!CreateProcessW(NULL, CommandLinePtr, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo))
- FATAL("CreateProcessW failed\n");
+ TESTEXCEPTION("CreateProcessW failed\n");
* You should always use the EXCEPTION or SSEXCEPTION macro for throwing this exception.
*
* @param Message
* You should always use the EXCEPTION or SSEXCEPTION macro for throwing this exception.
*
* @param Message
- * Constant pointer to a char array containing a short message about the exception
+ * String containing a short message about the exception
-CSimpleException::CSimpleException(const char* Message)
+CSimpleException::CSimpleException(const string& Message)
string m_Message;
public:
string m_Message;
public:
- CSimpleException(const char* Message);
+ CSimpleException(const string& Message);
const string& GetMessage() const { return m_Message; }
};
const string& GetMessage() const { return m_Message; }
};
--- /dev/null
+/*
+ * PROJECT: ReactOS Automatic Testing Utility
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE: Simple exception during test execution that can be skipped over
+ * COPYRIGHT: Copyright 2015 Thomas Faber <thomas.faber@reactos.org>
+ */
+
+class CTestException : public CSimpleException
+{
+public:
+ CTestException(const string& Message) : CSimpleException(Message) { }
+};
/* Wait till this process ended */
if(WaitForSingleObject(Process.GetProcessHandle(), ListTimeout) == WAIT_FAILED)
/* Wait till this process ended */
if(WaitForSingleObject(Process.GetProcessHandle(), ListTimeout) == WAIT_FAILED)
- FATAL("WaitForSingleObject failed for the test list\n");
+ TESTEXCEPTION("WaitForSingleObject failed for the test list\n");
}
/* Read the output data into a buffer */
if(!Pipe.Peek(NULL, 0, NULL, &BytesAvailable))
}
/* Read the output data into a buffer */
if(!Pipe.Peek(NULL, 0, NULL, &BytesAvailable))
- FATAL("CPipe::Peek failed for the test list\n");
+ TESTEXCEPTION("CPipe::Peek failed for the test list\n");
/* Check if we got any */
if(!BytesAvailable)
/* Check if we got any */
if(!BytesAvailable)
stringstream ss;
ss << "The --list command did not return any data for " << UnicodeToAscii(m_CurrentFile) << endl;
stringstream ss;
ss << "The --list command did not return any data for " << UnicodeToAscii(m_CurrentFile) << endl;
+ TESTEXCEPTION(ss.str());
}
/* Read the data */
m_ListBuffer = new char[BytesAvailable];
if(!Pipe.Read(m_ListBuffer, BytesAvailable, &Temp))
}
/* Read the data */
m_ListBuffer = new char[BytesAvailable];
if(!Pipe.Read(m_ListBuffer, BytesAvailable, &Temp))
- FATAL("CPipe::Read failed\n");
+ TESTEXCEPTION("CPipe::Read failed\n");
{
while(!m_CurrentFile.empty() || GetNextFile())
{
{
while(!m_CurrentFile.empty() || GetNextFile())
{
- /* If the user specified a test through the command line, check this here */
- if(!Configuration.GetTest().empty() && Configuration.GetTest() != m_CurrentTest)
- continue;
-
- auto_ptr<CTestInfo> TestInfo(new CTestInfo());
- size_t UnderscorePosition;
+ /* If the user specified a test through the command line, check this here */
+ if(!Configuration.GetTest().empty() && Configuration.GetTest() != m_CurrentTest)
+ continue;
- /* Build the command line */
- TestInfo->CommandLine = m_TestPath;
- TestInfo->CommandLine += m_CurrentFile;
- TestInfo->CommandLine += ' ';
- TestInfo->CommandLine += AsciiToUnicode(m_CurrentTest);
+ {
+ auto_ptr<CTestInfo> TestInfo(new CTestInfo());
+ size_t UnderscorePosition;
- /* Store the Module name */
- UnderscorePosition = m_CurrentFile.find_last_of('_');
+ /* Build the command line */
+ TestInfo->CommandLine = m_TestPath;
+ TestInfo->CommandLine += m_CurrentFile;
+ TestInfo->CommandLine += ' ';
+ TestInfo->CommandLine += AsciiToUnicode(m_CurrentTest);
- if(UnderscorePosition == m_CurrentFile.npos)
- {
- stringstream ss;
+ /* Store the Module name */
+ UnderscorePosition = m_CurrentFile.find_last_of('_');
- ss << "Invalid test file name: " << UnicodeToAscii(m_CurrentFile) << endl;
- SSEXCEPTION;
- }
+ if(UnderscorePosition == m_CurrentFile.npos)
+ {
+ stringstream ss;
+
+ ss << "Invalid test file name: " << UnicodeToAscii(m_CurrentFile) << endl;
+ SSEXCEPTION;
+ }
- TestInfo->Module = UnicodeToAscii(m_CurrentFile.substr(0, UnderscorePosition));
+ TestInfo->Module = UnicodeToAscii(m_CurrentFile.substr(0, UnderscorePosition));
- /* Store the test */
- TestInfo->Test = m_CurrentTest;
+ /* Store the test */
+ TestInfo->Test = m_CurrentTest;
- return TestInfo.release();
+ return TestInfo.release();
+ }
+ catch(CTestException& e)
+ {
+ delete[] m_ListBuffer;
+ StringOut(e.GetMessage());
+ m_CurrentFile.clear();
+ }
StartTime = GetTickCount();
StartTime = GetTickCount();
{
/* Execute the test */
CPipedProcess Process(TestInfo->CommandLine, Pipe);
{
/* Execute the test */
CPipedProcess Process(TestInfo->CommandLine, Pipe);
TestInfo->Log += Buffer;
}
if(GetLastError() != ERROR_BROKEN_PIPE)
TestInfo->Log += Buffer;
}
if(GetLastError() != ERROR_BROKEN_PIPE)
- FATAL("CPipe::Read failed for the test run\n");
+ TESTEXCEPTION("CPipe::Read failed for the test run\n");
+ }
+ catch(CTestException& e)
+ {
+ if(!tailString.empty())
+ StringOut(tailString);
+ tailString.clear();
+ StringOut(e.GetMessage());
+ TestInfo->Log += e.GetMessage();
}
/* Print what's left */
}
/* Print what's left */
ssFinish << "Test " << TestInfo->Test << " completed in ";
ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl;
StringOut(ssFinish.str());
ssFinish << "Test " << TestInfo->Test << " completed in ";
ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl;
StringOut(ssFinish.str());
+ TestInfo->Log += ssFinish.str();
#include "CProcess.h"
#include "CPipedProcess.h"
#include "CSimpleException.h"
#include "CProcess.h"
#include "CPipedProcess.h"
#include "CSimpleException.h"
+#include "CTestException.h"
#include "CTestInfo.h"
#include "CTest.h"
#include "CTestList.h"
#include "CTestInfo.h"
#include "CTest.h"
#include "CTestList.h"
#include <rosautotestmsg.h>
/* Useful macros */
#include <rosautotestmsg.h>
/* Useful macros */
-#define EXCEPTION(Message) throw CSimpleException(Message)
-#define FATAL(Message) throw CFatalException(__FILE__, __LINE__, Message)
-#define SSEXCEPTION throw CSimpleException(ss.str().c_str())
+#define EXCEPTION(Message) throw CSimpleException(Message)
+#define FATAL(Message) throw CFatalException(__FILE__, __LINE__, Message)
+#define SSEXCEPTION throw CSimpleException(ss.str())
+#define TESTEXCEPTION(Message) throw CTestException(Message)
/* main.c */
extern CConfiguration Configuration;
/* main.c */
extern CConfiguration Configuration;