Allow controlling collection timeout over environment variable VTEST_RUN_TIMEOUT. #79

This commit is contained in:
Roman Telezhynskyi 2020-11-12 16:01:10 +02:00
parent ce8f369d60
commit 34fd0b81bf
2 changed files with 22 additions and 0 deletions

View File

@ -352,9 +352,29 @@ QString AbstractTest::TranslationsPath() const
return QCoreApplication::applicationDirPath() + QStringLiteral("/../../../app/valentina/bin/translations");
}
//---------------------------------------------------------------------------------------------------------------------
int AbstractTest::RunTimeout(int defMsecs)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
QString timeout = QString::fromLocal8Bit(qgetenv("VTEST_RUN_TIMEOUT"));
if (timeout.isEmpty())
{
return defMsecs;
}
#else
QString timeout = qEnvironmentVariable("VTEST_RUN_TIMEOUT", QString::number(msecs));
#endif
bool ok = false;
int msecs = timeout.toInt(&ok);
return ok ? msecs : defMsecs;
}
//---------------------------------------------------------------------------------------------------------------------
int AbstractTest::Run(int exit, const QString &program, const QStringList &arguments, QString &error, int msecs)
{
msecs = AbstractTest::RunTimeout(msecs);
const QString parameters = QStringLiteral("Program: %1 \nArguments: %2.")
.arg(program, arguments.join(QStringLiteral(", ")));

View File

@ -85,6 +85,8 @@ protected:
QString TapePath() const;
QString TranslationsPath() const;
static int RunTimeout(int defMsecs);
int Run(int exit, const QString &program, const QStringList &arguments, QString &error, int msecs = 120000);
bool CopyRecursively(const QString &srcFilePath, const QString &tgtFilePath) const;