forked from qt-creator/qt-creator
AutoTest: Fix handling exceptions while environment setup
If setting up the environment for gtest fails due to an exception we might end up having no reportable result but we get a return code of 1 for the test application. Inform the results pane instead of just ignoring the return code and explicitly send a fatal result for this. Task-number: QTCREATORBUG-20280 Change-Id: I05e522764d6302c5b0760c4bc10e01a2248a4494 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -48,16 +48,20 @@ GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResultPtr> &futu
|
||||
, m_executable(testApplication ? testApplication->program() : QString())
|
||||
, m_projectFile(projectFile)
|
||||
{
|
||||
// on Windows abort() will result in normal termination, but exit code will be set to 3
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
connect(m_testApplication,
|
||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||
this, [this] (int exitCode, QProcess::ExitStatus /*exitStatus*/) {
|
||||
if (exitCode == 3)
|
||||
if (exitCode == 1 && !m_description.isEmpty()) {
|
||||
// TODO tr()
|
||||
const QString message{"Running test(s) failed\n" + m_description
|
||||
+ "\nExecutable: " + m_executable};
|
||||
createAndReportResult(message, Result::MessageFatal);
|
||||
}
|
||||
// on Windows abort() will result in normal termination, but exit code will be set to 3
|
||||
if (Utils::HostOsInfo::isWindowsHost() && exitCode == 3)
|
||||
reportCrash();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
||||
{
|
||||
|
@@ -74,6 +74,14 @@ void TestOutputReader::reportCrash()
|
||||
m_futureInterface.reportResult(result);
|
||||
}
|
||||
|
||||
void TestOutputReader::createAndReportResult(const QString &message, Result::Type type)
|
||||
{
|
||||
TestResultPtr result = createDefaultResult();
|
||||
result->setDescription(message);
|
||||
result->setResult(type);
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
void TestOutputReader::reportResult(const TestResultPtr &result)
|
||||
{
|
||||
m_futureInterface.reportResult(result);
|
||||
|
@@ -45,6 +45,7 @@ public:
|
||||
virtual void processOutput(const QByteArray &outputLine) = 0;
|
||||
virtual void processStdError(const QByteArray &output);
|
||||
void reportCrash();
|
||||
void createAndReportResult(const QString &message, Result::Type type);
|
||||
bool hadValidOutput() const { return m_hadValidOutput; }
|
||||
|
||||
signals:
|
||||
|
Reference in New Issue
Block a user