No points to show warnings if we excpect error in test.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-01 21:02:14 +03:00
parent 655a297f73
commit 30cfa143fe
3 changed files with 25 additions and 13 deletions

View File

@ -72,15 +72,18 @@ QString AbstractTest::TapePath() const
}
//---------------------------------------------------------------------------------------------------------------------
bool AbstractTest::Run(const QString &program, const QStringList &arguments)
bool AbstractTest::Run(bool showWarn, const QString &program, const QStringList &arguments)
{
const QString parameters = QString("Program: %1 \nArguments: %2.").arg(program).arg(arguments.join(", "));
QFileInfo info(program);
if (not info.exists())
{
if (showWarn)
{
const QString msg = QString("Can't find binary.\n%1").arg(parameters);
QWARN(qUtf8Printable(msg));
}
return false;
}
@ -89,25 +92,34 @@ bool AbstractTest::Run(const QString &program, const QStringList &arguments)
process->start(program, arguments);
if (not process->waitForFinished())// 30 sec
{
if (showWarn)
{
const QString msg = QString("The operation timed out or an error occurred.\n%1").arg(parameters);
QWARN(qUtf8Printable(msg));
}
return false;
}
if (process->exitStatus() == QProcess::CrashExit)
{
if (showWarn)
{
const QString msg = QString("Program crashed.\n%1\n%2").arg(parameters)
.arg(QString(process->readAllStandardError()));
QWARN(qUtf8Printable(msg));
}
return false;
}
if (process->exitCode() != 0)
{
if (showWarn)
{
const QString msg = QString("Failed.\n%1\n%2").arg(parameters)
.arg(QString(process->readAllStandardError()));
QWARN(qUtf8Printable(msg));
}
return false;
}

View File

@ -43,7 +43,7 @@ protected:
QString ValentinaPath() const;
QString TapePath() const;
bool Run(const QString &program, const QStringList &arguments);
bool Run(bool showWarn, const QString &program, const QStringList &arguments);
bool CopyRecursively(const QString &srcFilePath, const QString &tgtFilePath) const;
};

View File

@ -70,7 +70,7 @@ void TST_TapeCommandLine::OpenMeasurements()
QFETCH(QString, file);
QFETCH(bool, result);
const bool res = Run(TapePath(), QStringList() << "--test"
const bool res = Run(result, TapePath(), QStringList() << "--test"
<< QApplication::applicationDirPath() + QLatin1Char('/') + tmpTestFolder + QLatin1Char('/') + file);
QCOMPARE(res, result);