AutoTest: Fix timeout handling

Qt5.5 introduced a hard limit of 5 minutes for the test
case run.
If the timeout configured inside the settings is higher
and the test case runs longer than the the internal
default the test would crash ignoring the timeout set
by the user. Qt5.6.1 fixed this by adding a capability
to raise this limit.
Handle the hard limit used inside QTest appropriate.

Task-number: QTCREATORBUG-20439
Change-Id: I33f1d9bce4e503be7175228dde50b4484e57d337
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-05-18 06:55:30 +02:00
parent a1a78c4c69
commit f129ed9d96

View File

@@ -195,14 +195,15 @@ void TestRunner::scheduleNext()
QProcessEnvironment environment = m_currentConfig->environment().toProcessEnvironment();
if (Utils::HostOsInfo::isWindowsHost())
environment.insert("QT_LOGGING_TO_CONSOLE", "1");
const int timeout = AutotestPlugin::settings()->timeout;
if (timeout > 5 * 60 * 1000) // Qt5.5 introduced hard limit, Qt5.6.1 added env var to raise this
environment.insert("QTEST_FUNCTION_TIMEOUT", QString::number(timeout));
m_currentProcess->setProcessEnvironment(environment);
connect(m_currentProcess,
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
this, &TestRunner::onProcessFinished);
QTimer::singleShot(AutotestPlugin::settings()->timeout, m_currentProcess, [this]() {
cancelCurrent(Timeout);
});
QTimer::singleShot(timeout, m_currentProcess, [this]() { cancelCurrent(Timeout); });
m_currentProcess->start();
if (!m_currentProcess->waitForStarted()) {