forked from qt-creator/qt-creator
Ensure that after a call to waitForFinished() process is not running
Amends 5de5f1cf0a
Change-Id: I64db8c6736c6a7cc6805813f852faf1048ebb629
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -169,6 +169,11 @@ private:
|
|||||||
QHash<QString, QString> m_map;
|
QHash<QString, QString> m_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void doCrash()
|
||||||
|
{
|
||||||
|
qFatal("The application has crashed purposefully!");
|
||||||
|
}
|
||||||
|
|
||||||
class tst_QtcProcess : public QObject
|
class tst_QtcProcess : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -1320,7 +1325,7 @@ void tst_QtcProcess::flushFinishedWhileWaitingForReadyRead()
|
|||||||
|
|
||||||
void tst_QtcProcess::EmitOneErrorOnCrash::main()
|
void tst_QtcProcess::EmitOneErrorOnCrash::main()
|
||||||
{
|
{
|
||||||
abort();
|
doCrash();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QtcProcess::emitOneErrorOnCrash()
|
void tst_QtcProcess::emitOneErrorOnCrash()
|
||||||
@@ -1339,12 +1344,13 @@ void tst_QtcProcess::emitOneErrorOnCrash()
|
|||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
QCOMPARE(errorCount, 1);
|
QCOMPARE(errorCount, 1);
|
||||||
|
QCOMPARE(process.error(), QProcess::Crashed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QtcProcess::CrashAfterOneSecond::main()
|
void tst_QtcProcess::CrashAfterOneSecond::main()
|
||||||
{
|
{
|
||||||
QThread::sleep(1);
|
QThread::sleep(1);
|
||||||
abort();
|
doCrash();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QtcProcess::crashAfterOneSecond()
|
void tst_QtcProcess::crashAfterOneSecond()
|
||||||
@@ -1361,6 +1367,8 @@ void tst_QtcProcess::crashAfterOneSecond()
|
|||||||
// it doesn't (try running this test with QTC_USE_QPROCESS=)
|
// it doesn't (try running this test with QTC_USE_QPROCESS=)
|
||||||
QVERIFY(process.waitForFinished(2000));
|
QVERIFY(process.waitForFinished(2000));
|
||||||
QVERIFY(timer.elapsed() < 2000);
|
QVERIFY(timer.elapsed() < 2000);
|
||||||
|
QCOMPARE(process.state(), QProcess::NotRunning);
|
||||||
|
QCOMPARE(process.error(), QProcess::Crashed);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QtcProcess)
|
QTEST_MAIN(tst_QtcProcess)
|
||||||
|
Reference in New Issue
Block a user