forked from qt-creator/qt-creator
Add a test for a crash in ModelManagerInterface
Task-number: QTCREATORBUG-25350 Change-Id: I4ea31e7936cc77dcd8f3fc494b5ecbd83858a766 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1393,6 +1393,12 @@ void PluginManagerPrivate::shutdown()
|
|||||||
shutdownEventLoop->exec();
|
shutdownEventLoop->exec();
|
||||||
}
|
}
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
if (PluginManager::isScenarioRunning("TestModelManagerInterface")) {
|
||||||
|
qDebug() << "Point 2: Expect the next call to Point 3 triggers a crash";
|
||||||
|
QThread::currentThread()->sleep(5);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!allObjects.isEmpty()) {
|
if (!allObjects.isEmpty()) {
|
||||||
qDebug() << "There are" << allObjects.size() << "objects left in the plugin manager pool.";
|
qDebug() << "There are" << allObjects.size() << "objects left in the plugin manager pool.";
|
||||||
// Intentionally split debug info here, since in case the list contains
|
// Intentionally split debug info here, since in case the list contains
|
||||||
|
@@ -40,6 +40,10 @@
|
|||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -969,6 +973,16 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths,
|
|||||||
doc->setSource(contents);
|
doc->setSource(contents);
|
||||||
doc->parse();
|
doc->parse();
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
if (ExtensionSystem::PluginManager::isScenarioRunning("TestModelManagerInterface")) {
|
||||||
|
ExtensionSystem::PluginManager::waitForScenarioFullyInitialized();
|
||||||
|
if (ExtensionSystem::PluginManager::finishScenario()) {
|
||||||
|
qDebug() << "Point 1: Shutdown triggered";
|
||||||
|
QThread::currentThread()->sleep(2);
|
||||||
|
qDebug() << "Point 3: If Point 2 was already reached, expect a crash now";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// update snapshot. requires synchronization, but significantly reduces amount of file
|
// update snapshot. requires synchronization, but significantly reduces amount of file
|
||||||
// system queries for library imports because queries are cached in libraryInfo
|
// system queries for library imports because queries are cached in libraryInfo
|
||||||
const Snapshot snapshot = modelManager->snapshot();
|
const Snapshot snapshot = modelManager->snapshot();
|
||||||
|
@@ -280,6 +280,8 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
|
|||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
ExtensionSystem::PluginManager::registerScenario("TestStringTable",
|
ExtensionSystem::PluginManager::registerScenario("TestStringTable",
|
||||||
[this]() { return dd->m_loadProjectScenario(); });
|
[this]() { return dd->m_loadProjectScenario(); });
|
||||||
|
ExtensionSystem::PluginManager::registerScenario("TestModelManagerInterface",
|
||||||
|
[this]() { return dd->m_loadProjectScenario(); });
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -308,13 +308,23 @@ void AutoTestUnitTests::testCodeParserBoostTest_data()
|
|||||||
<< QString(m_tmpDir->path() + "/simple_boost/simple_boost.qbs") << QString(".qbs");
|
<< QString(m_tmpDir->path() + "/simple_boost/simple_boost.qbs") << QString(".qbs");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTestUnitTests::testStringTable()
|
static int executeScenario(const QString &scenario)
|
||||||
{
|
{
|
||||||
const PluginManager::ProcessData data = PluginManager::creatorProcessData();
|
const PluginManager::ProcessData data = PluginManager::creatorProcessData();
|
||||||
QStringList additionalArgs{ "-scenario", "TestStringTable" };
|
QStringList additionalArgs{ "-scenario", scenario };
|
||||||
if (!data.m_args.contains("-settingspath") && !data.m_settingsPath.isEmpty())
|
if (!data.m_args.contains("-settingspath") && !data.m_settingsPath.isEmpty())
|
||||||
additionalArgs << "-settingspath" << data.m_settingsPath;
|
additionalArgs << "-settingspath" << data.m_settingsPath;
|
||||||
QCOMPARE(QProcess::execute(data.m_executable, data.m_args + additionalArgs), 0);
|
return QProcess::execute(data.m_executable, data.m_args + additionalArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoTestUnitTests::testStringTable()
|
||||||
|
{
|
||||||
|
QCOMPARE(executeScenario("TestStringTable"), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoTestUnitTests::testModelManagerInterface()
|
||||||
|
{
|
||||||
|
QCOMPARE(executeScenario("TestModelManagerInterface"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -56,6 +56,7 @@ private slots:
|
|||||||
void testCodeParserBoostTest();
|
void testCodeParserBoostTest();
|
||||||
void testCodeParserBoostTest_data();
|
void testCodeParserBoostTest_data();
|
||||||
void testStringTable();
|
void testStringTable();
|
||||||
|
void testModelManagerInterface();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestTreeModel *m_model = nullptr;
|
TestTreeModel *m_model = nullptr;
|
||||||
|
Reference in New Issue
Block a user