tst_QSharedPointer: Fix termination of external processes on Windows
Timeouts with subsequent failures to delete the temporary directories have been observed in COIN. Previously, QProcess:terminate() was used to end the processes, which does not have any effect on console processes on Windows. Add a helper function which resorts to kill() on failure to terminate(). Change-Id: I05539d1703280d34b392f2e8ff8565b9a04d703c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
f1d227bceb
commit
b624cdac21
@ -42,6 +42,7 @@
|
|||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QLibraryInfo>
|
#include <QtCore/QLibraryInfo>
|
||||||
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#ifndef DEFAULT_MAKESPEC
|
#ifndef DEFAULT_MAKESPEC
|
||||||
# error DEFAULT_MAKESPEC not defined
|
# error DEFAULT_MAKESPEC not defined
|
||||||
@ -69,6 +70,16 @@ static QString makespec()
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace QTest {
|
namespace QTest {
|
||||||
#if QT_CONFIG(process)
|
#if QT_CONFIG(process)
|
||||||
|
static void ensureStopped(QProcess &process)
|
||||||
|
{
|
||||||
|
if (process.state() == QProcess::Running) {
|
||||||
|
process.terminate();
|
||||||
|
QThread::msleep(20);
|
||||||
|
if (process.state() == QProcess::Running)
|
||||||
|
process.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class QExternalProcess: public QProcess
|
class QExternalProcess: public QProcess
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -594,7 +605,7 @@ namespace QTest {
|
|||||||
ok = qmake.waitForFinished();
|
ok = qmake.waitForFinished();
|
||||||
exitCode = qmake.exitCode();
|
exitCode = qmake.exitCode();
|
||||||
if (!ok)
|
if (!ok)
|
||||||
qmake.terminate();
|
QTest::ensureStopped(qmake);
|
||||||
|
|
||||||
std_out += qmake.readAllStandardOutput();
|
std_out += qmake.readAllStandardOutput();
|
||||||
std_err += qmake.readAllStandardError();
|
std_err += qmake.readAllStandardError();
|
||||||
@ -661,7 +672,7 @@ namespace QTest {
|
|||||||
make.closeWriteChannel();
|
make.closeWriteChannel();
|
||||||
bool ok = make.waitForFinished(channelMode == QProcess::ForwardedChannels ? -1 : 60000);
|
bool ok = make.waitForFinished(channelMode == QProcess::ForwardedChannels ? -1 : 60000);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
make.terminate();
|
QTest::ensureStopped(make);
|
||||||
exitCode = make.exitCode();
|
exitCode = make.exitCode();
|
||||||
std_out += make.readAllStandardOutput();
|
std_out += make.readAllStandardOutput();
|
||||||
std_err += make.readAllStandardError();
|
std_err += make.readAllStandardError();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user